LIFO Principle
The last element added to the stack will be the first element removed from it. This is exactly how a stack of plates works in a cafeteria.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
A Stack is a linear data structure that follows a particular order in which operations are performed. The order is LIFO (Last In First Out).
The last element added to the stack will be the first element removed from it. This is exactly how a stack of plates works in a cafeteria.
Unlike arrays where you can access any index, a Stack restricts your access to only one end—the Top. All insertions and deletions happen here.
A Stack can be implemented using contiguous memory (Arrays) or scattered memory (Linked Lists). The Abstract Data Type (ADT) remains the same regardless of the underlying memory.