Presentation is loading. Please wait.

Presentation is loading. Please wait.

STACK Data Structure www.btechsmartclass.com.

Similar presentations


Presentation on theme: "STACK Data Structure www.btechsmartclass.com."— Presentation transcript:

1 STACK Data Structure

2 A stack is a ordered list of elements of same data type
What is a STACK ? A stack is a container of elements that are inserted and removed according to the last-in first-out (LIFO) principle. A stack is a ordered list of elements of same data type A stack is a Linear list

3 What is a STACK ? In a stack all operation like insertion and deletion are performed at only one end called Top 1 2 3 4

4 What is a STACK ? Insertion Deletion In a stack all operation like insertion and deletion are performed at only one end called Top 4 Top 3 2 1

5 Operations on STACK ? Creation Insertion Deletion Displaying

6 Operations on STACK ? Creation Insertion Deletion Displaying 4
#define SIZE 5   int stack[SIZE]; Creation 3 Insertion 2 Deletion 1 Displaying stack

7 Operations on STACK ? Creation Insertion Deletion Displaying 4 3 2 1
Insertion operation is called as “push” 4 void push(element){ if(Stack is full) { printf(“FULL!!!”); } else Top++; stack[Top] = element; Creation 3 Insertion 2 Deletion 1 Displaying stack

8 Operations on STACK ? Creation Insertion Deletion Displaying 4 3 2 1
Deletion operation is called as “pop” 4 int pop( ){ if(Stack is Empty) { printf(“EMPTY!!!”); return Top; } else deleted = stack[Top]; Top--; return deleted; Creation 3 Insertion 2 Deletion 1 Displaying stack

9 Operations on STACK ? Creation Insertion Deletion Displaying 4 3 2 1
void display( ){ if(Stack is Empty) { printf(“EMPTY!!!”); } else for(i=Top; i>-1; i--) printf(“%d\n”,stack[i]); Creation 3 Insertion 2 Deletion 1 Displaying stack


Download ppt "STACK Data Structure www.btechsmartclass.com."

Similar presentations


Ads by Google