You need to find the k smallest elements in an unsorted array of size n. Which approach is optimal using a heap?
Build a min-heap of all elements and extract k times
Build a max-heap of size k
Use a min-priority queue to keep track of k smallest
Build a max-heap of all elements
This question is part of this quiz :
Quiz on Heap