0% found this document useful (0 votes)
47 views11 pages

Stack and Queue Data Structure Quiz

The document contains a series of questions related to data structures, specifically focusing on stacks and queues. It covers fundamental concepts such as LIFO and FIFO principles, operations like push, pop, enqueue, and dequeue, and applications of these data structures in algorithms and programming. Additionally, it addresses time complexities and specific use cases for stacks and queues.

Uploaded by

jeyojo4691
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views11 pages

Stack and Queue Data Structure Quiz

The document contains a series of questions related to data structures, specifically focusing on stacks and queues. It covers fundamental concepts such as LIFO and FIFO principles, operations like push, pop, enqueue, and dequeue, and applications of these data structures in algorithms and programming. Additionally, it addresses time complexities and specific use cases for stacks and queues.

Uploaded by

jeyojo4691
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Stack and queue questions

1. Which data structure follows the Last-In-First-Out (LIFO) principle?


a) Stack
b) Queue
c) Linked list
d) Tree
2. In a stack, the element that is at the top is referred to as the:
a) Front
b) Rear
c) Head
d) Top
3. Which operation adds an element to the top of a stack?
a) Push
b) Pop
c) Enqueue
d) Dequeue
4. Which operation removes the top element from a stack?
a) Push
b) Pop
c) Enqueue
d) Dequeue
5. The process of removing all the elements from a stack is called:
a) Popping
b) Emptying
c) Clearin d) Depleting
6. Which data structure follows the First-In-First-Out (FIFO) principle?
a) Stack
b) Queue
c) Linked list
d) Tree
7. In a queue, the element that is at the front is referred to as the:
a) Front
b) Rear
c) Head
d) Top
8. Which operation adds an element to the back of a queue?
a) Push
b) Pop
c) Enqueue
d) Dequeue
9. Which operation removes the front element from a queue?
a) Push
b) Pop
c) Enqueue
d) Dequeue
10. The process of removing all the elements from a queue is called:
a) Popping
b) Emptying
c) Clearing
d) Depleting
11. Which data structure can be implemented using arrays or linked
lists?
a) Stack
b) Queue
c) Both stack and queue
d) Neither stack nor queue
12. Which data structure is used in the depth-first search (DFS)
algorithm?
a) Stack
b) Queue
c) Linked list
d) Array
13. Which data structure is used in the breadth-first search (BFS)
algorithm?
a) Stack
b) Queue
c) Linked list
d) Array
14. Which operation in a stack or queue returns the element without
removing it?
a) Peek
b) Poll
c) Pop
d) Dequeue
15. Which operation in a stack or queue removes and returns the
element?
a) Push c) Pop
b) Pol d) Dequeue
16. A double-ended queue that supports insertion and deletion at both
ends is called:
a) Stack
b) Queue
c) Deque
d) Linked list
17. Which data structure can be used to implement an undo feature in
text editors?
a) Stack
b) Queue
c) Deque
d) Linked list
18. In a circular queue, what happens when the front and rear pointers
meet?
a) The queue becomes empty
b) The queue becomes full
c) Elements are shifted to the right
d) Elements are shifted to the left
19. Which operation is used to insert an element at the rear of a queue?
a) Push
b) Enqueue
c) Pop
d) Dequeue
20. Which operation is used to remove an element from the front of a
queue?
a) Push
b) Enqueue
c) Pop
d) Dequeue
21. Which data structure is suitable for implementing a printer spooler?
a) Stack
b) Queue
c) Deque
d) Linked list
22. Which data structure can be used to reverse the order of elements
efficiently?
a) Stack
b) Queue
c) Deque
d) Linked list
23. Which data structure is used in implementing function calls in
programming languages?
a) Stack
b) Queue
c) Deque
d) Linked list
24. In a priority queue, elements are retrieved based on their:
a) First-In-First-Out (FIFO) order
b) Last-In-First-Out (LIFO) order
c) Order of insertion
d) Priority level
25. Which data structure is typically implemented using a dynamic array
or a linked list?
a) Stack
b) Queue
c) Deque
d) Priority queue
26. Which data structure is used to implement function call tracking in
programming languages?
a) Stack
b) Queue
c) Linked list
d) Array
27. Which data structure ensures that the most recently added element
is the first to be removed?
a) Stack
b) Queue
c) Deque
d) Priority queue
28. Which data structure maintains elements in sorted order based on
their priority?
a) Stack
b) Queue
c) Deque
d) Priority queue
29. What happens when you try to pop an element from an empty stack?
a) The program crashes
b) An error message is displayed
c) The stack is cleared
d) The operation is ignored
30. What is the time complexity of pushing an element onto a stack with
n elements?
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
31. What is the time complexity of popping an element from a stack with
n elements?
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
32. Which operation in a queue removes and returns the front element?
a) Poll
b) Pop
c) Dequeue
d) Remove
33. What is the time complexity of enqueuing an element into a queue
with n elements?
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
34. What is the time complexity of dequeuing an element from a queue
with n elements?
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
35. Which type of queue allows elements to be inserted and removed
from both ends?
a) Priority queue
b) Circular queue
c) Double-ended queue (Deque)
d) Linear queue
36. Which data structure uses a circular buffer to manage its elements?
a) Stack
b) Queue
c) Priority queue
d) Circular queue
37. What is the key property of a priority queue that differentiates it from
a regular queue?
a) Elements are sorted in ascending order
b) Elements are sorted in descending order
c) Elements are inserted based on their value
d) Elements are inserted based on their priority level

38. Which operation in a priority queue returns the element with the
highest priority?
a) Poll
b) Pop
c) Dequeue
d) Remove
39. Which operation in a priority queue removes and returns the
element with the highest priority?
a) Poll
b) Pop
c) Dequeue
d) Remove
40. Which data structure is used in breadth-first search (BFS) to explore
nodes level by level?
a) Stack
b) Queue
c) Deque
d) Priority queue
41. Which data structure is used in depth-first search (DFS) to explore
nodes along a path as deeply as possible?
a) Stack
b) Queue
c) Deque
d) Priority queue
42. Which data structure can be used to implement the "undo" feature in
a word processing application?
a) Stack
b) Queue
c) Deque
d) Priority queue
43. Which data structure can be implemented using both arrays and
linked lists?
a) Stack
b) Queue
c) Deque
d) Priority queue
44. In a priority queue, which element will be removed first?
a) The smallest element
b) The largest element
c) The element with the lowest priority
d) The element with the highest priority
45. Which data structure can be used to reverse a string efficiently?
a) Stack
b) Queue
c) Deque
d) Priority queue
46. Which operation is used to add an element at the back of a queue?
a) Enqueue
b) Dequeue
c) Push
d) Pop
47. Which operation is used to remove an element from the front of a
queue?
a) Enqueue
b) Dequeue
c) Push
d) Pop
48. Which data structure can be used to manage tasks in a printer
spooler?
a) Stack
b) Queue
c) Deque
d) Priority queue
49. In a circular queue, what happens when the front and rear pointers
meet?
a) The queue becomes empty
b) The queue becomes full
c) Elements are shifted to the right
d) Elements are shifted to the left
50. Which data structure can be used to implement a scheduling
algorithm?
a) Stack
b) Queue
c) Deque
d) Priority queue

You might also like