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?

  1. A. 10
  2. B. 11
  3. C. 17
  4. 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.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic