Uday starts learning the application of STACK which are:
(A) To reverse a string.
(B) To match the parenthesis in an arithmetic expression.
(C) For spooling printer jobs.
(D) To trace back the last visited web page on a website by using BACK button of the browser.
Uday starts learning the application of STACK which are:
(A) To reverse a string.
(B) To match the parenthesis in an arithmetic expression.
(C) For spooling printer jobs.
(D) To trace back the last visited web page on a website by using BACK button of the browser.
Solution
A stack follows LIFO (Last In, First Out), so it suits tasks that need the most recent item first.
(A) Reversing a string: push each character, then pop them all, and they come out in reverse order.
(B) Matching parentheses: push each opening bracket and pop it when its closing bracket appears.
(D) Browser BACK button: the most recently visited page is on top of the stack and is the first one returned to.
(C) Printer spooling: jobs must be printed in the order they arrive (FIFO), so it uses a queue, not a stack. This is the trap in Options 1, 2 and 3.
Related questions:
2026: 18 May Shift 2
2025: 16 May Shift 1
2025: 14 May Shift 1
2026: 24 May Shift 1