Professional Documents
Culture Documents
What is an array – is a linear container / data structure that holds data of the same type.
Char arr
Each location of an element has a numerical index. Elements are stored in a contiguous memory
location. An index is always less than the total number of array items. Any variable that is
ARRAY OPERATION
Transversal
Insertion
Searching
Sorting
#include <Stdio.h>
Int main ()
Return 0;
} //end main
Insertion of an element can be done at the beginning, at the end or at a given index of an array.
Int main {
N++
Array [0]=item;
}
getch ();
return 0;
Data 07
Data 06
Data 05
Data 04
Data 03
Data 02
Data 01
When writing a program it is always important to focus on the problem however real world
problems are complex in nature. It therefor important to break down this in to their most
fundamental part and describe these parts in a simple way in a process called abstraction.
Through abstraction, we develop a model of the problem. This gives us the abstract of the
problem and in many case we have the data and the operations.
Temperature is low: measure
Heater:-
Suggest
An abstract data type- is a mathematical model / logical model, of a data structure that
Arrays
Lists
Maps
Vectors
Problem
model
It is a linear data structure where elements are stacked on top of each other, only the last element
added can be accessed from the top since a stack is a lasting first out
Stacks have a number of operations but the main operations are three which include
Push
Pop
Peek/ top
Element 7
Element 6
Element 5
Element 4
Element 3
Element 2
Element 1
Element
Stack data structures are useful when the order of actions is important. They ensure that the
system does move to a new action before completing the ones before
For example
(i) If you wanted to reverse a string such as “Hello World!” we will push each character into a
(iii) When playing some games that involve a pack and a dead is reached and you can backtrack
(iv) Programming languages use a data stack to execute code i.e. when a function is called it is
#include <iostream>
#include <stack>
Int main ()
Stack1.Push (100);
Stock 1. Pop ()
Stack 1.pop()
Example 2
#include <iostream>
#include <stack>
Cout <<’/n’;
Int main ()
Stack<Int>st;
Cout <<”\n to remove the top element we use St. Pop ()”
St. Pop ()
Return 0 ;}