LIFO and FIFO structures and their uses
A stack allows push, pop and top in O(1) time and follows the last-in first-out order. It underlies function call management, undo features, and balanced parenthesis checking.
A queue inserts at the rear and removes from the front in first-in first-out order. A circular queue reuses freed slots and avoids wasted space, and queues drive scheduling and breadth-first search.
Stacks convert infix expressions to postfix and evaluate them, and check balanced brackets, while the C++ STL supplies ready made std stack and std queue containers.
This unit presented stacks and queues, their array and linked implementations, and key applications such as expression evaluation, scheduling and graph traversal.