adplus-dvertising
frame-decoration

Question

If the sequence of operations -

push(1)
push(2)
pop
push(1)
push(2)
pop
pop
pop
push(2)
pop

are performed on a stack, the sequence of popped out values are ?

a.

2 2 1 2 2

b.

2 2 1 1 2

c.

2 1 2 2 1

d.

2 1 2 2 2

Answer: (b).2 2 1 1 2

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. If the sequence of operations - push(1) push(2) pop push(1) push(2) pop pop pop push(2) pop are performed on a stack, the sequence of popped out values are ?

Similar Questions

Discover Related MCQs

Q. Stack cannot be used to

Q. Expression
1 * 2 ^ 3 * 4 ^ 5 * 6
is evaluated as -

Q. Which of the following is useful in the implementation of quick sort ?

Q. List of data in which element can be inserted and removed at the same end is called as __________.

Q. Adding element to stack means ___________.

Q. Pushing element in the stack means _____________.

Q. Post fix form of following infix expression is -
(A + B) * (C + D - E) * F

Q. Post fix form of following infix expression is -
* + A B - C D

Q. Stack can be implemented using ___________ and _________.

Q. Well formed parenthesis can be checked using following data structure ?

Q. Post fix form of
A + (B * C)
is -

Q. Post fix form of -
(A + B) * C

Q. 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?

Q. If memory for the run-time stack is only 150 cells(words), how big can N be in Factorial(N) before stack overflow?

Q. 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 ?

Q. 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 ?

Q. Which of the following is a collection of items into which items can be inserted arbitrarity and from which only the smallest item can be removed?

Q. A priority queue is used to implement a stack S that stores characters PUSH(C)is implemented as INSERT(Q,C,K)where K is an appropriate integer key chosen by the implementation.POP is implemented as DELETEMIN(Q)(Q). For a sequence of operations, the keys chosen are in

Q. Queues serve major role in

Q. Which of the following data structure may give overflow error,even though the current number of element in it is less than its size?