Past exam question: 2066 Bhadra (Regular / Back), Q1(b)
Open in the Padhaiko appQuestion
and write applications of stacks.
Solution
Core Applications of Stacks:
- Expression Conversion & Evaluation: Infix-to-postfix/prefix conversion and postfix evaluation.
- Function Calls & Recursion: Storing activation records and return addresses on the system call stack.
- Balanced Parenthesis & Syntax Checking: Matching
{ },[ ],( )in compilers. - Undo/Redo & Backtracking: Browser history, editor undo, and Depth-First Search (DFS).
Answer:
Stacks are used in expression conversion/evaluation, recursion/function call frames, parenthesis matching, undo/redo buffers, and DFS/backtracking.