ALGORITHM : PUSH(STACK,TOP,VALUE,SIZE)
1.If TOP=SIZE-1, then:
print overflow and Exit.
2.Set TOP=TOP+1.
3.STACK[TOP+1]=VALUE.
4.Exit.
ALGORITHM : PUSH(STACK,TOP)
1.If TOP=-1, then:
print underflow and Exit.
2.print STACK[TOP].
3.Set TOP=TOP-1.
4.Exit
1.If TOP=SIZE-1, then:
print overflow and Exit.
2.Set TOP=TOP+1.
3.STACK[TOP+1]=VALUE.
4.Exit.
ALGORITHM : PUSH(STACK,TOP)
1.If TOP=-1, then:
print underflow and Exit.
2.print STACK[TOP].
3.Set TOP=TOP-1.
4.Exit
ALGORITHM : TRAVERSAL(STACK,TOP)
1.If TOP=-1, then:
print stack is empty and Exit.
2.[Initialize Counter]Set I=TOP.
3.Repeat steps 4 and 5 while I<=0 :
4.print STACK[I].
5.[Increase Counter]Set I=I-1.
[End Of Loop.]
6.Exit.
1.If TOP=-1, then:
print stack is empty and Exit.
2.[Initialize Counter]Set I=TOP.
3.Repeat steps 4 and 5 while I<=0 :
4.print STACK[I].
5.[Increase Counter]Set I=I-1.
[End Of Loop.]
6.Exit.
If you have any suggestions regarding this post, please comment below in the comment section.
No comments