Recall & Review
beginner
What is a Min Heap?
A Min Heap is a special tree-based data structure where the parent node is always smaller than or equal to its child nodes. This means the smallest element is always at the root.
Click to reveal answer
beginner
How does a Min Heap help find the kth smallest element?
By building a Min Heap from the array, the smallest element is at the root. Removing the root k-1 times and then looking at the root gives the kth smallest element.
Click to reveal answer
intermediate
What is the time complexity of finding the kth smallest element using a Min Heap?
Building the Min Heap takes O(n) time. Removing the root k times takes O(k log n) time. So overall, it is O(n + k log n).
Click to reveal answer
beginner
What operation is used to remove the smallest element from a Min Heap?
The operation is called 'extractMin'. It removes the root (smallest element) and then re-adjusts the heap to maintain the Min Heap property.
Click to reveal answer
intermediate
Why is a Min Heap preferred over sorting the entire array to find the kth smallest element?
Using a Min Heap can be more efficient because it avoids sorting the entire array, especially when k is small compared to n. It focuses only on extracting the smallest elements needed.
Click to reveal answer
What is the root of a Min Heap?
✗ Incorrect
In a Min Heap, the root is always the smallest element.
Which operation removes the smallest element from a Min Heap?
✗ Incorrect
extractMin removes the root, which is the smallest element in a Min Heap.
What is the time complexity to build a Min Heap from an array of size n?
✗ Incorrect
Building a Min Heap from an array takes O(n) time.
To find the 3rd smallest element using a Min Heap, how many times do you extract the minimum?
✗ Incorrect
You extract the minimum k-1 times (2 times for k=3), then the root is the kth smallest.
Why might using a Min Heap be better than sorting the whole array to find the kth smallest element?
✗ Incorrect
Min Heap focuses on extracting the smallest elements needed, which can be faster than sorting the entire array.
Explain step-by-step how to find the kth smallest element using a Min Heap.
Think about how the smallest elements come out first in a Min Heap.
You got /3 concepts.
Describe the advantages of using a Min Heap over sorting the entire array for finding the kth smallest element.
Consider time saved by partial extraction instead of full sorting.
You got /4 concepts.