Stack and LIFO
A Stack is a linear data structure that follows the LIFO principle: Last In, First Out. The most recently inserted element is the first element removed. A stack typically exposes operations such as push, pop, and peek, all of which can be implemented in O(1) time.
Insertion and deletion happen at the same end, called the top.
LIFO means the newest element is processed first.
Typical operations are O(1).
Stacks can be implemented using arrays, dynamic arrays, or linked lists.
Common uses include function calls, expression evaluation, undo operations, and backtracking.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience