Consider these functions:
push() : push an element into the stack
pop() : pop the top-of-the-stack element
top() : returns the item stored in top-of-the-stack-node
What will be the output after performing these sequence of operations.
push(20);
push(4);
top();
pop();
pop();
push(5);
top();
push(20);
push(4);
top();
pop();
pop();
push(5);
top();A. 20
B. 4
C. stack underflow
D. 5
Answer: Option D
Related Questions on Introduction to Data Structures
A. A collection of data values
B. A programming language
C. A set of algorithms
D. A way of organizing and storing data

Join The Discussion