Unit 2 - Linked Stack
Unit 2 - Linked Stack
College : VGEC
The drawback of using array method is fixed size, but
in this method it’s removed.
In a linked stack, every node has two parts : one that
stores data and another that stores the address of the
next node.
Linked Stack
• To insert an element with value 8, we first check if
TOP=NULL.
• If this is the case, then we allocate memory for a new
node, store the value in its DATA part and NULL in its
NEXT part.
• The new node will then be called TOP.
• If TOP!=NULL, then we insert the new node at the
beginning of the linked stack and name this new
node as TOP.
TOP