Data Structures & AlgorithmsVery hardGATE CS · ISRO Scientist
A min-heap starts empty. The operations, in order, are: insert 2, delete-min, insert 19, insert 11, insert 15, insert 3, insert 18, insert 4, insert 10, insert 17, insert 1, delete-min. Here insert adds a value and delete-min removes the current smallest value. Among the values still stored, what is the 6-th smallest?
- A. 10
- B. 11
- C. 17
- D. 15
Correct answer: C. 17
The stored multiset is what remains after the delete-mins, so the answer is the k-th smallest of that multiset. Heap positions are not sorted, and the values removed by delete-min must not be counted.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- A min-heap starts empty. The operations, in order, are: insert 16, insert 8, insert 15, delete-min, insert 6, insert 1, insert 18, insert…
- A min-heap starts empty. The operations, in order, are: insert 7, insert 11, insert 15, insert 17, delete-min, insert 16, insert 14…
- A min-heap starts empty. The operations, in order, are: insert 19, insert 19, insert 6, delete-min, insert 9, insert 2, insert 3, insert…
- A min-heap starts empty. The operations, in order, are: insert 4, insert 3, insert 10, delete-min, delete-min, insert 4, insert 1, insert…
- An undirected connected graph on vertices 0 to 4 has these weighted edges: 0-1 (w=9), 0-2 (w=6), 0-4 (w=10), 1-2 (w=2), 1-3 (w=3), 1-4…
- An undirected connected graph on vertices 0 to 6 has these weighted edges: 0-1 (w=11), 0-2 (w=11), 0-4 (w=2), 0-5 (w=6), 1-2 (w=7), 1-3…