Skip to main contentSkip to solution

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

✅ Correct Option: 4

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question