Embed presentation
Download to read offline




![ALGORITHM OF INSERTION IN STACK: (PUSH)
1. Insertion(a,top,item,max)
2. If top=max then
3. print ‘STACK OVERFLOW’
4. exit else
5. top=top+1 end if
6. a[top]=item
7. Exit](https://image.slidesharecdn.com/stackoperationalgorithmswithexample-210614134113/85/Stack-operation-algorithms-with-example-5-320.jpg)
![ALGORITHM OF DELETION IN STACK: (POP)
1. Deletion(a,top,item)
2. If top=0 then
3. print ‘STACK UNDERFLOW’
4. exit else
5. item=a[top] end if
6. top=top-1
7. Exit](https://image.slidesharecdn.com/stackoperationalgorithmswithexample-210614134113/85/Stack-operation-algorithms-with-example-6-320.jpg)
![ALGORITHM OF DISPLAY IN STACK:
• 1. Display(top,i,a[i]) 2.If top=0 then
• 2. Print ‘STACK EMPTY’
• Exit Else
• 3. For i=top to 0
• Print a[i] End for
• 4. exit](https://image.slidesharecdn.com/stackoperationalgorithmswithexample-210614134113/85/Stack-operation-algorithms-with-example-7-320.jpg)




This document discusses stacks and algorithms for common stack operations. It defines a stack as a last-in, first-out data structure where the last item added is the first removed. The key operations are PUSH to insert an item and POP to remove an item from the top. Algorithms are provided for PUSH, POP, and displaying the stack. As an example, the document shows the steps to convert an infix notation expression to postfix.




![ALGORITHM OF INSERTION IN STACK: (PUSH)
1. Insertion(a,top,item,max)
2. If top=max then
3. print ‘STACK OVERFLOW’
4. exit else
5. top=top+1 end if
6. a[top]=item
7. Exit](https://image.slidesharecdn.com/stackoperationalgorithmswithexample-210614134113/85/Stack-operation-algorithms-with-example-5-320.jpg)
![ALGORITHM OF DELETION IN STACK: (POP)
1. Deletion(a,top,item)
2. If top=0 then
3. print ‘STACK UNDERFLOW’
4. exit else
5. item=a[top] end if
6. top=top-1
7. Exit](https://image.slidesharecdn.com/stackoperationalgorithmswithexample-210614134113/85/Stack-operation-algorithms-with-example-6-320.jpg)
![ALGORITHM OF DISPLAY IN STACK:
• 1. Display(top,i,a[i]) 2.If top=0 then
• 2. Print ‘STACK EMPTY’
• Exit Else
• 3. For i=top to 0
• Print a[i] End for
• 4. exit](https://image.slidesharecdn.com/stackoperationalgorithmswithexample-210614134113/85/Stack-operation-algorithms-with-example-7-320.jpg)


