CMC
Company
Programming
Technical
The following operations are performed on a stack:
push(10), push(20), pop, push(10), push(20), pop, pop, pop, push(20), pop. The sequence of values popped out is
A) 20, 10, 20, 10, 20
B) 20, 20, 10, 10, 20
C) 10, 20, 20, 10, 20
D) 20, 20, 10, 20, 10
Read Solution (Total 8)
-
- 20 20 10 10 20
- 10 years agoHelpfull: Yes(2) No(0)
- B IS THE ANSWR
- 9 years agoHelpfull: Yes(0) No(0)
- 20 20 10 10 20
- 9 years agoHelpfull: Yes(0) No(0)
- 20 20 10 10 20
- 9 years agoHelpfull: Yes(0) No(0)
- ans B because push will push to top and pop also remove top
- 9 years agoHelpfull: Yes(0) No(0)
- for the 1st two push stack will be like 20
10
pop=20(in stack 10 will be there)
for another two push 20
10
10
pop=20,10,10
push=20
pop=20
so sequence will be like=20,20,10,10,20
- 8 years agoHelpfull: Yes(0) No(0)
- B is the right answer
- 7 years agoHelpfull: Yes(0) No(0)
- 20 20 10 10 20
- 5 years agoHelpfull: Yes(0) No(0)
CMC Other Question