Professional Documents
Culture Documents
DS, Stacks Types of DS
DS, Stacks Types of DS
i. Stack i. Tree
ii. Queue ii. Graph
iii. Linked List iii. etc.
Linear List Arrays
Arrays refer to a named list of a finite number n of same type of elements.
8 0 1 3 4 2
0 1 2 3 4 5
Stacks
There’s a special way to store lists where we use LIFO technique.
12& N
U
DATA DATA
120
49&
haus L
bbcc L
1 5 2
1 2
Operations on DS DS
Stacks
There’s a special way to store lists where we use LIFO technique.
13 13
7 8 8 8 8 8
4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 5 5
S S S S S S S S S S S
Stacks
3 3
13 13 13 13
8 8 8 8 8
4 4 4 4 4 4
5 5 5 5 5 5 5
S S S S S S S S S
Implementing Stack
To implement a stack we need to make its functions.
1. isEmpty(s)
2. Push(s,i) ‘Ghantu’
3. Pop(s)
‘Mintu’
4. Peek(s)
5. Display(s) ‘Pintu’
‘Chintu’
We need to maintain top of stack, and make it None when stack is empty.
STACK IMPLEMENT CODE