DS Stacks & Queues: 17 MCQs with answers
All 17 multiple-choice questions from this kit, free and with no sign-up.
Warm-up · 8 questions
Q1. Which data structure follows the Last-In-First-Out (LIFO) principle?
BeginnerShow answer & explanation
Stack
A stack processes the most recently added element first, which is the LIFO principle.
Q2. In a queue, which operation removes an element?
BeginnerShow answer & explanation
dequeue
Dequeue removes the front element from a queue, while enqueue adds to the rear.
Q3. What is the primary difference between a stack and a queue?
BeginnerShow answer & explanation
Stack is LIFO, queue is FIFO
Stack follows Last-In-First-Out, while queue follows First-In-First-Out.
Q4. Which operation adds an element to the rear of a queue?
BeginnerShow answer & explanation
enqueue
Enqueue adds an element to the rear of a queue.
Q5. Which of the following is NOT a valid operation on a stack?
BeginnerShow answer & explanation
enqueue
Enqueue is an operation for queues, not stacks.
Q6. In a stack, which element is accessible?
BeginnerShow answer & explanation
The top element
Only the top element of a stack is directly accessible.
Q7. A stack allows insertion and deletion at both ends.
BeginnerShow answer & explanation
False
A stack allows insertion and deletion only at one end, called the top.
Q8. A queue follows the First-In-First-Out (FIFO) principle.
BeginnerShow answer & explanation
True
A queue processes elements in the order they were added, which is FIFO.
Building up · 6 questions
Q9. What is the time complexity of the push operation on a stack implemented as a linked list?
IntermediateShow answer & explanation
$O(1)$
Pushing onto a linked-list stack adds a node at the head, which takes constant time.
Q10. Which of the following applications typically uses a stack?
IntermediateShow answer & explanation
Function call management
Stacks are used to manage function calls, including return addresses and local variables.
Q11. What is the time complexity of the pop operation on a stack implemented as an array?
IntermediateShow answer & explanation
$O(1)$
Popping from an array-based stack removes the top element, which is a constant-time operation.
Q12. Which data structure is used in breadth-first search (BFS) of a graph?
IntermediateShow answer & explanation
Queue
BFS uses a queue to explore nodes level by level.
Q13. What is the time complexity of the dequeue operation on a queue implemented as a linked list?
IntermediateShow answer & explanation
$O(1)$
Dequeue removes the front node, which takes constant time in a linked-list queue.
Q14. Which application uses a queue?
IntermediateShow answer & explanation
Printer spooling
Printer spooling uses a queue to manage print jobs in order.
Topper level · 3 questions
Q15. In a circular queue of capacity $n$, what is the condition for a full queue when using a front and rear index?
AdvancedShow answer & explanation
$(rear + 1) \% n = front$
A circular queue is full when the next position of rear would be front.
Q16. What is the condition for an empty queue when using front and rear indices?
AdvancedShow answer & explanation
$front = rear$
An empty queue is typically indicated when front equals rear.
Q17. What is the time complexity of the enqueue operation on a circular queue implemented as an array?
AdvancedShow answer & explanation
$O(1)$
Enqueue in a circular queue adds an element at the rear and updates the rear index, which is constant time.
Your notes can be a kit like these
Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.
- Chapter notes
- Flashcards
- Practice MCQs
- Scored tests
- Exam prep
Get Veda free See what students get
Free to start · No ads · Works in 42 languages