1. : Which data structure is primarily used to implement a priority queue?
(A) Array
(B) Linked List
(C) Stack
(D) Heap
2. : What is the time complexity of inserting an element into a priority queue implemented using a heap of size 𝑛?
(A) O(1)
(B) O(log n)
(C) O(n)
(D) O(n log n)
3. : Which sorting algorithm uses a heap as its data structure?
(A) Merge sort
(B) Quick sort
(C) Bubble sort
(D) Heap sort
4. : What is the worst-case time complexity of heap sort for sorting 𝑛 elements?
(A) O(n)
(B) O(log n)
(C) O(n log n)
(D) O(n^2)
5. : In heap sort, what is the process used to build a max-heap from an array?
(A) Bubble up
(B) Bubble down
(C) Heapify
(D) Merge
6. : Which of the following is a primary advantage of using a priority queue?
(A) Faster deletion operations
(B) Guaranteed constant-time access
(C) Efficient retrieval of the maximum element
(D) Ability to store elements in any order
7. : Which operation is typically used to remove the maximum element from a max-heap in a priority queue?
(A) Extract min
(B) Extract max
(C) Delete
(D) Remove
8. : In a min-heap-based priority queue, what operation retrieves the minimum element without removing it?
(A) Peek
(B) Poll
(C) Pop
(D) Remove
9. : Which sorting algorithm exhibits a stable behavior (preserves the relative order of equal elements)?
(A) Quick sort
(B) Heap sort
(C) Merge sort
(D) Bubble sort
10. : Which property of heap sort makes it suitable for applications requiring in-place sorting?
(A) Stable sorting
(B) Adaptive sorting
(C) Recursive sorting
(D) In-place sorting
11. : Which operation is used to convert an unordered array into a heap in heap sort?
(A) Insertion
(B) Deletion
(C) Heapify
(D) Merge
12. : What is the main disadvantage of using a heap-based priority queue compared to other data structures?
(A) Slower insertion operations
(B) Limited to fixed-size elements
(C) Unstable retrieval of maximum element
(D) Higher memory usage
13. : Which application often requires efficient priority queue operations?
(A) Sorting names alphabetically
(B) Implementing a scheduler for tasks
(C) Counting occurrences of elements
(D) Finding shortest paths in a graph
14. : In a priority queue implemented using a min-heap, what is the root element?
(A) Smallest element
(B) Largest element
(C) Median element
(D) Arbitrary element
15. : Which data structure does not use a heap for its implementation?
(A) Binary Search Tree
(B) AVL Tree
(C) Red-Black Tree
(D) Heap Tree
16. : What is the primary benefit of using heap sort over other sorting algorithms?
(A) Stable sorting
(B) Adaptive sorting
(C) Worst-case time complexity
(D) Ease of implementation
17. : Which operation in a priority queue is similar to removing the root in a heap?
(A) Peek
(B) Poll
(C) Push
(D) Pop
18. : Which property must be maintained during the heapify process in heap sort?
(A) Parent node should be greater than both child nodes.
(B) Parent node should be less than both child nodes.
(C) Parent node should be equal to both child nodes.
(D) Parent node should be greater than or equal to both child nodes.
19. : Which operation is not typically supported directly by a heap-based priority queue?
(A) Insertion
(B) Deletion of arbitrary elements
(C) Merge of two priority queues
(D) Extracting the minimum element
20. : Which sorting algorithm is generally preferred when stable sorting is not a requirement?
(A) Merge sort
(B) Heap sort
(C) Bubble sort
(D) Insertion sort