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 is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.
Many students prefer Teachoo Black for a smooth, ad-free learning experience.
Go ad-free with Teachoo Black
Adblock detected
Skip every ad. Keep every answer.
Teachoo Black gives you a clean, uninterrupted study experience on every page.