Implement stack using linked list.

Push operation of stack

Pop operation of stack

Step 1: Input the DATA to be pushed

Step 2: Create a New Node

Step 3: NewNode -> DATA = DATA

Step 4: NewNode -> Next = TOP

Step 5: TOP = NewNode

Step 6: Exit

Step 1: if(TOP==NULL)

             Display “The stack is empty” and

             go to step 5

             else TEMP = TOP

Step 2: Display “The popped element

              TOP -> DATA”

Step 3: TOP = TOP -> Next

Step 4: TEMP -> Next = NULL and Free the

              Temp node

Step 5: Exit

 

Share with

Comments 0

Add your comment