Stacks and Queues MCQs, Set 1 of 1
Q1 / 12
Q1. A stack follows which order?
- A.FIFO
- B.LIFO(correct answer)
- C.Random
- D.Sorted
Last In, First Out: the most recently pushed item is removed first.
Q2. A queue follows which order?
- A.LIFO
- B.FILO
- C.FIFO(correct answer)
- D.Sorted
First In, First Out: items leave in the order they arrived.
Q3. Which operation adds an element to the top of a stack?
- A.Enqueue
- B.Push(correct answer)
- C.Pop
- D.Peek
Push adds to the top; pop removes from the top; peek reads the top.
Q4. After push(1), push(2), push(3), pop(), what is on top of the stack?
- A.1
- B.2(correct answer)
- C.3
- D.The stack is empty
pop() removes 3, leaving 2 on top.
Q5. Which data structure manages function calls in most programming languages?
- A.Queue
- B.Heap
- C.Call stack(correct answer)
- D.Hash table
Each call pushes a frame; returning pops it, so the last call made returns first.
Q6. Breadth-first search (BFS) on a graph usually uses a:
- A.Stack
- B.Queue(correct answer)
- C.Priority queue
- D.Binary tree
A queue makes BFS visit nodes level by level.
Q7. What is the postfix form of the infix expression A + B * C?
- A.A B C * +(correct answer)
- B.A B + C *
- C.+ A * B C
- D.A B C + *
* has higher precedence, so B * C becomes B C *, then adding A gives A B C * +.
Q8. What happens when you pop from an empty stack?
- A.Stack overflow
- B.Stack underflow(correct answer)
- C.It returns the bottom element
- D.The stack doubles in size
Removing from an empty stack is called underflow; pushing onto a full one is overflow.
Q9. A queue where items can be added or removed at both ends is called a:
- A.Priority queue
- B.Circular queue
- C.Deque(correct answer)
- D.Stack
Deque means double-ended queue.
Q10. In a priority queue, which element is removed first?
- A.The oldest element
- B.The newest element
- C.The element with the highest priority(correct answer)
- D.A random element
Removal order depends on priority, not on arrival time.
Q11. Which data structure is commonly used to check for balanced parentheses?
- A.Queue
- B.Stack(correct answer)
- C.Linked list
- D.Graph
Push each opening bracket and pop when the matching closing bracket appears.
Q12. What is the time complexity of push and pop on a stack built from a linked list?
- A.O(1)(correct answer)
- B.O(log n)
- C.O(n)
- D.O(n log n)
Both operations only touch the head node.