in DS recategorized by
4,893 views
0 votes
0 votes

Given an empty stack, after performing push(1), push(2), pop, push(3), push(4), pop, pop, push(5), pop, what is the value of the top of the stack?

  1. 4
  2. 3
  3. 2
  4. 1
in DS recategorized by
4.9k views

2 Answers

3 votes
3 votes
Best answer
Operation push(1) push(2) pop push(3) push(4) pop pop push(5) pop
          4        
    2   3 3 3   5  
  1 1 1 1 1 1 1 1 1

Hence,Option(D)1 is the correct choice.

selected by
2 votes
2 votes

Answer: 1

Push 1    Push 2

 1    Pop 2

1     Push 3    Push 4 

1     Pop 4     Pop 3

1     Push 5  

1     Pop 5

1    <=== Answer

Answer:

Related questions