Algorithm for Stack using linked list
Algorithm:
Step1: Start
Step2: Read the case in ch
Step3: Switch ch
Case1, perform push function
Case2, perform pop function
Case3,perform status function
Case4, exit
Step4: push function
1.initialize the node
2.Read the data to data[Newnode]
3.link[Newnode]=top
4.header=top
pop function
1.if top=null,then print stack underflow
2.else
Set ptr=link[top]
link[header]=ptr
free(top)
top=ptr
status function
Print the elements of the stack
Step5: stop
Comments
Post a Comment