PRACTICE • LEARN • GROW
Heap & Priority Queue MCQs
Solve topic-wise placement questions and improve your skills.
Heap & Priority Queue Progress
0 of 20 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What is the defining structural property of a Binary Heap?
A.
It is a Complete Binary Tree (all levels filled except possibly the last, which is filled from left to right)
B.
It is a Full Binary Tree where every node has 0 or 2 children
C.
It is a Degenerate Tree similar to a linked list
D.
It has no balance requirements
Explanation & Key
Correct Answer:
2
In a 0-indexed array representation of a binary heap, what is the index of the left child of node at index `i`?
A.
2 * i
B.
2 * i + 1
C.
2 * i + 2
D.
i / 2
Explanation & Key
Correct Answer:
3
In a 0-indexed array representation of a binary heap, what is the parent index of node at index `i` (for i > 0)?
A.
(i - 1) / 2
B.
i / 2
C.
2 * i - 1
D.
(i + 1) / 2
Explanation & Key
Correct Answer:
4
What is the heap property in a Min-Heap?
A.
The key of every node is less than or equal to the keys of its children
B.
The root always stores the maximum value
C.
Left child is always smaller than right child
D.
All leaf nodes have equal keys
Explanation & Key
Correct Answer:
5
What is the time complexity to retrieve (peek) the minimum element in a Min-Heap?
A.
O(1)
B.
O(log N)
C.
O(N)
D.
O(N log N)
Explanation & Key
Correct Answer:
6
What is the time complexity of inserting a new element into a binary heap of size N?
A.
O(1)
B.
O(log N)
C.
O(N)
D.
O(N log N)
Explanation & Key
Correct Answer:
7
What is the time complexity of extracting the root (minimum/maximum) from a binary heap of size N?
A.
O(1)
B.
O(log N)
C.
O(N)
D.
O(N^2)
Explanation & Key
Correct Answer:
8
What is the time complexity to build a binary heap from an arbitrary unsorted array of N elements using the bottom-up `buildHeap` algorithm?
A.
O(N log N)
B.
O(N)
C.
O(N^2)
D.
O(log N)
Explanation & Key
Correct Answer:
9
What is the overall worst-case time complexity of Heap Sort on an array of N elements?
A.
O(N)
B.
O(N log N)
C.
O(N^2)
D.
O(log N)
Explanation & Key
Correct Answer:
10
Is standard Heap Sort an in-place and stable sorting algorithm?
A.
It is in-place (O(1) space), but NOT stable
B.
It is stable, but requires O(N) auxiliary space
C.
It is both in-place and stable
D.
It is neither in-place nor stable
Explanation & Key
Correct Answer:
11
How can you find the K-th largest element in an unsorted stream of N numbers most efficiently in O(N log K) time?
A.
Maintain a Min-Heap of size K; if the incoming number is greater than heap root, pop and push
B.
Maintain a Max-Heap of size N
C.
Sort the entire array on every insertion
D.
Use a linear queue
Explanation & Key
Correct Answer:
12
What is the default ordering of `std::priority_queue` in C++ STL?
A.
Max-Heap (greatest element on top)
B.
Min-Heap (smallest element on top)
C.
First-in, First-out (FIFO)
D.
Sorted in random order
Explanation & Key
Correct Answer:
13
In Java, what does `new PriorityQueue()` construct by default?
A.
Max-Heap
B.
Min-Heap
C.
Double-ended priority queue
D.
Bounded deque
Explanation & Key
Correct Answer:
14
In Python's `heapq` module, which function transforms a regular list `x` into a min-heap in-place?
A.
heapq.heapify(x)
B.
heapq.sort(x)
C.
heapq.create(x)
D.
heapq.make_heap(x)
Explanation & Key
Correct Answer:
15
What data structure is used in Dijkstra's Shortest Path algorithm to select the next nearest unvisited node in O(log V) time?
A.
Min-Priority Queue / Min-Heap
B.
Max-Heap
C.
Stack
D.
Circular linked list
Explanation & Key
Correct Answer:
16
What is the time complexity of searching for an arbitrary element in an unsorted Binary Heap of size N?
A.
O(log N)
B.
O(N)
C.
O(1)
D.
O(N log N)
Explanation & Key
Correct Answer:
17
How does the "Median from Data Stream" problem maintain the running median in O(log N) insertion time?
A.
Using two heaps: a Max-Heap for the smaller half and a Min-Heap for the larger half
B.
Using a single binary search tree without balancing
C.
Sorting the array every time an element arrives
D.
Using two stacks
Explanation & Key
Correct Answer:
18
What is a Fibonacci Heap known for in algorithmic analysis?
A.
Amortized O(1) time for `insert` and `decrease-key` operations
B.
Being the simplest heap to implement
C.
Requiring no pointer storage
D.
Replacing arrays in all standard libraries
Explanation & Key
Correct Answer:
19
In a D-ary heap (where each node has D children instead of 2), what is the height of the heap with N elements?
A.
O(log_D N)
B.
O(D * N)
C.
O(N / D)
D.
O(D^N)
Explanation & Key
Correct Answer:
20
When merging K sorted linked lists with a total of N nodes, what is the optimal time complexity using a Min-Heap?
A.
O(N * K)
B.
O(N log K)
C.
O(K log N)
D.
O(N^2)
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong