Stack Using Linked
List –
POP Operation
NAME: MOHD. MASIULLAH TAHA
ROLL NO: 24H51A6742
Introduction to Stacks
•Definition: A stack is a linear data structure that follows the LIFO (Last In, First Out)
principle.
Main Operations:
•PUSH – insert element
•POP – remove element
Applications:
•Expression evaluation
•Undo features
•Function calls
Stack Implementation Types
•Two main ways to implement a stack:
• Using Arrays
• Fixed size, fast access
• Using Linked Lists
• Dynamic size, efficient for memory
•This presentation focuses on linked list implementation.
Linked List-Based Stack
Concept:
•Each node contains data and a pointer to the next node.
•The top pointer always points to the most recently added
node.
Stack Node Structure (C
Code)
POP Operation
•Definition: Removes the top element of the stack.
•Steps:
1.Check if the stack is empty (top == NULL)
2.Store the top node in a temp pointer
3.Move top to the next node
4.Free the removed node
POP Operation - C Code
Conclusion
•Summary:
•POP removes the most recent item from the stack.
•Linked list allows dynamic memory usage.
•Advantages of Linked List Stack:
•No size limit
•Efficient memory use
THANK YOU