Stacks and Queues
1. Which among the following represents a stack?
2. What is the time complexity of a push operation in a stack? What is the time complexity of a pop operation in a stack?
3. Consider these operations on an empty stack: push(3), push(5), pop(), push(10), push(11), pop(), push(100). What will be the stack configuration? The first number is the top of the stack and the last number is the bottom.
4. If a stack is initially empty and the operations push(4), push(7), push(9), pop(), push(12) are performed, which element is at the top?
5. Which operation allows the top element of a stack to be inspected without removing it?
6. What condition occurs when a pop operation is attempted on an empty stack?
7. A stack is used to evaluate a postfix expression. Which property of the stack makes it suitable for this task?
8. A stack is implemented using an array of capacity 5. If the stack already contains 5 elements, what happens when another push operation is attempted?
9. Which sequence of operations on an empty stack results in 20 being at the top while 10 remains below it?