data structure, stack, stack data structure

3,220 views
3,052 views

Published on

Published in: Education, Technology
0 Comments
13 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,220
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
328
Comments
0
Likes
13
Embeds 0
No embeds

No notes for slide

data structure, stack, stack data structure

  1. 1. Stack Presentation on Stack By Patta Jagadeeswara Rao, Software Engineer, Patta Jagadeeswara Rao, MCA.
  2. 2. Introduction to Stack  A Stack is a Linear Data Structure.  The Data Items in the stack are inserted and deleted from one end. That is called Top of the stack.   Stack follows LIFO (Last In First Out) Mechanism. Stacks are mostly used in system software. Like compilers and Operating Systems, etc..  Insert values into stack is called push operation.  Reading Values from stack is called pop operation. Patta Jagadeeswara Rao, MCA.
  3. 3. Introduction to Stack (Cont..)  The Stack starts with position of 0(zero) .  The Maximum Position of Stack is n-1.    When The position of Stack is zero. Then, the stack is underflow. When The position of Stack is grater than n-1. Then, the stack is called overflow. Once an item is popped from stack, it is no longer available. Patta Jagadeeswara Rao, MCA.
  4. 4. Stack Operations     There are Two operations in stack. Those are push and pop. The push operation is used to insert the values into stack. The pop operation is used to Retrieve the values from the stack. The best example for stack is the bunch of plates in the kitchen. Patta Jagadeeswara Rao, MCA.
  5. 5. Example for stack # include <stdio.h> # include <conio.h> char jaggu[100]; int top = 0; void push(void); void pop(void); void main() { Patta Jagadeeswara Rao, MCA.
  6. 6. Example for stack(cont..) Int ch = 0; while(1) { printf(“1. Add new item”); printf(“2. Delete item”); printf(“3. Quit”); printf(“Enter Your Choice :”); scanf(“%d”, &ch); Patta Jagadeeswara Rao, MCA.
  7. 7. Example for Stack(cont..) switch(ch) { case 1: push(); break; case 2: pop(); break; case 3: return; }}} Patta Jagadeeswara Rao, MCA.
  8. 8. Example for Stack(cont..) Void push(void) { if(top >=100) { printf(“stack if full”); return; } else Patta Jagadeeswara Rao, MCA.
  9. 9. Example for stack(cont..) { printf(“ The item is : %ch”, gets(jaggu[top])); if(!jaggu[top]) { top ++; } } Patta Jagadeeswara Rao, MCA.
  10. 10. Example for stack(cont..) Void pop(void) { top - - ; if(top < 0) { printf(“stack is empty”); return; } printf(“The item is :%ch”, jaggu[top]);} Patta Jagadeeswara Rao, MCA.
  11. 11. Thank You Patta Jagadeeswara Rao, MCA.

×