LAB MANUAL
IT2205 – Data Structures and Algorithm Lab
INDEX
1. Array Implementation Of Stack
2. Application Of Stack – Conversion Of Infix To Postfix
3. Implementation Of Linear Queue Using Arrays
4. Array Implementation Of Circular Queue
5. Linked List Implementation Of Stack
6. Singly linked list – Linked list implementation
7. Doubly linked list – Linked list implementation
8. Polynomial Manipulation
9. Tree Traversals
10. Expression Tree
11. Priority Queue Using Heap
12. Hashing Technique
13. Dijkstra’s Algorithm
14. Back tracking algorithm – knap sack problem
Ex. no.: 1
Date :
ARRAY IMPLEMENTATION OF STACK
Aim
To write a C-program to implement stack using array data structure.
And perform the following stack operations
1. POP
2. PUSH
3. PEEP
Algorithm
STEP 1:Start
STEP 2:Initialize stack, will=1,i, num
STEP 3:Add element in stack
PUSH(S,TOP,X)
3.a. [Check overflow condition]
If(TOP>=N) then
Write(“Stack is full”)
3.b. [Insert element]
[Increment TOP]
TOP =1)
post[j++]=pop();
push(2);
break;
case '*':
while(stack[top]>=3)
post[j++]=pop();
push(3);
break;
case '/':
while(stack[top]>=3)
post[j++]=pop();
push(4);
break;
case '^':
while(stack[top]>=4)
post[j++]=pop();
push(5);
break;
case '(':
push(0);
break;
case ')':
while(stack[top]!=0)
post[j++]=pop();
top--;
break;
default:
post[j++]=inf[i];
}