Data Structures

1: Following sequence of operations is performed on a stack push(1),push(2),pop, push(1),push(2)pop,pop,pop,push(2),pop.The sequence of poped out values are
A. 2,2,1,1,2
B. 2,2,1,2,2
C. 2,1,2,2,1
D. 2,1,2,2,2
 

Answer : A

Explanation :

Gaurav Dutt said: (3:49pm on Saturday 18th May 2013)
push:- 1,2; Stack:- 1,2pop:- 2; Stack:- 1;push:- 1,2; Stack:- 1,1,2;pop,pop,pop:- 2,1,1; Stack:- becomes empty;push:- 2; Stack:- 2;pop:- 2; Stack:- becomes empty;Sequence of pop:- 2,2,1,1,2

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.