SRM INSTITUTE OF SCIENCE
 AND TECHNOLOGY,
 Kattankulathur
School of Computing
21CSC201J – Data Structures and Algorithms
Topic: Stack Implementation Using Linked Lists
Activity: Fill in the Missing Pseudocode
Consider that a stack is implemented using a Linked List (Pointer
Implementation). Fill the missing Pseudocode for Push and Pop operation.
The TOP pointer points to top of Satck.
Push Operation - Algorithm to insert an element VAL in a stack
Step 1: Allocate MEMORY for the new node and name it as NEW_NODE
Step 2: SET NEW_NODE → DATA= VAL
Step 3: IF TOP = NULL
SET NEW_NODE → NEXT = NULL
SET TOP =NEW_NODE
ELSE
SET NEW_NODE → NEXT= TOP
SET TOP= NEW_NODE
[END OF IF]
Step 4: END
Pop Operation - Algorithm to delete an element from a stack
Step 1: IF TOP = NULL
PRINT UNDERFLOW
Goto Step 5
[END OF IF]
Step 2: SET PTR = TOP
Step 3: SET TOP = TOP → NEXT
Step 4: FREE PTR
Step 5: END