Algorithm for Stack using array
Algorithm:
Step1: Start
Step2: Read the case in ch and array size to n
Step3: Switch ch
Case1,
if top>=n-1, then print stack is overflow
else,
Read the element to item
Set tpo=top+1
a[top]=item
Case2,
if top<0, then print stack is underflow
else
Set a[top]=null
top=top-1
Case3,exit
Step4: print the Stack
Step5: stop
Comments
Post a Comment