Stack MCQ : Puzzles ( Multiple Choice)


Congratulations - you have completed Data Structure.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%


Your answers are highlighted below.
Question 1
Consider following Scenario -
  1. The five items : P,Q,R,S and T are inserted into stack A one after other starting from T in reverse order
  2. The stack is popped three times and each element is inserted into another stack B.
  3. Then two elements are deleted from the stack B and pushed back onto the stack A.
What are the topmost elements of stack A and Stack B respectively?
A
R P
B
Q P
C
Q R
D
R Q
Question 1 Explanation: 
Stack Final Values
Question 2
If memory for the run-time stack is only 150 cells(words), how big can N be in Factorial(N) before stack overflow?
A
66
B
26
C
12
D
60
Question 3
A postfix expression is just the reverse of the prefix expression !
A
False
B
True
Question 4
Stack A has 3 Elements in it Say X,Y and Z with X on top.
  1. Stack B is empty.
  2. An Element popped out from Stack A can be printed immediately or pushed to stack B.
  3. An Element popped out from Stack B can only be printed.
In this arrangement, which of the following permutations of X,Y,Z are not possible ?
A
Y X Z
B
Z X Y
C
Y Z X
D
Z Y X
Question 4 Explanation: 
Consider Y X Z :
  1. X is Popped from Stack A and Pushed to Stack B
  2. Y gets printed.
  3. X is Popped from Stack B and Printed.
  4. Z is Popped from Stack A and Printed.
Consider Y Z X :
  1. X is Popped from Stack A and Pushed to Stack B
  2. Y is Popped from Stack A and Printed.
  3. Z is Popped from Stack A and Printed.
  4. X is Popped from Stack B and Printed.
Consider Z Y X :
  1. X is Popped from Stack A and Pushed to Stack B
  2. Y is Popped from Stack A and Pushed to Stack B
  3. Z is Popped from Stack A and Printed.
  4. Y is Popped from Stack B and Printed.
  5. X is Popped from Stack B and Printed.
Question 5
An item that is read as input can be either pushed to a stack and later popped and printed, or printed directly. Which of the following will be the output if the input is the sequence of items 1, 2, 3, 4, 5 ?
A
3 4 5 2 1
B
3 4 5 1 2
C
1 5 2 3 4
D
5 4 3 1 2
Once you are finished, click the button below. Any items you have not completed will be marked incorrect. Get Results
There are 5 questions to complete.