Question 1 Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack are
(A) 1 (B) 2 (C) 3 (D) 4
push(1)
Element 1 is inserted into the empty stack
pop( )
Element 1 is deleted from the stack and the stack becomes empty
push(2)
Element 2 is inserted into the empty stack
push(3)
Element 3 is inserted into the stack
pop( )
Element 3 is deleted from the stack
push(4)
Element 4 is inserted into the stack
pop( )
Element 4 is deleted from the stack
pop( )
Element 2 is deleted from the stack and the stack becomes empty
push(5)
Element 5 is inserted into the stack and the final stack has 1 element
Made by
Davneet Singh
Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo
Hi, it looks like you're using AdBlock :(
Displaying ads are our only source of revenue. To help Teachoo create more content, and view the ad-free version of Teachooo... please purchase Teachoo Black subscription.
Please login to view more pages. It's free :)
Teachoo gives you a better experience when you're logged in. Please login :)
Solve all your doubts with Teachoo Black!
Teachoo answers all your questions if you are a Black user!