Assume P, D, Q, R is the input sequence for a STACK.
Arrange the given operation to get the output as shown in the STACK below:
STACK R Q P
(A) POP(D)
(B) PUSH(P)
(C) PUSH(D)
(D) PUSH(R)
(E) PUSH(Q)
Assume P, D, Q, R is the input sequence for a STACK.
Arrange the given operation to get the output as shown in the STACK below:
| STACK |
|---|
| R |
| Q |
| P |
(A) POP(D)
(B) PUSH(P)
(C) PUSH(D)
(D) PUSH(R)
(E) PUSH(Q)
Solution
Input order is P, D, Q, R, and the final stack must have P at the bottom, then Q, then R on top. D must be pushed and then removed, so it never stays in the stack.
| Operation | Stack (bottom to top) |
|---|---|
| (B) PUSH(P) | P |
| (C) PUSH(D) | P, D |
| (A) POP(D) | P |
| (E) PUSH(Q) | P, Q |
| (D) PUSH(R) | P, Q, R |
The stack ends as P, Q, R from bottom to top, which matches the given figure with R on top.
Option 3: POP is attempted when only P is in the stack, so it would remove P instead of D.
Option 4: the order C, B pushes D before P, which breaks the input sequence P, D, Q, R.
Related questions:
2026: 24 May Shift 1
2025: 30 May Shift 2
2025: 22 May Shift 1
2026: 23 May Shift 2