Question: For some positive integer k, desing a data structure that supports the following two operations: Insert(x), which inserts a new item x into the data
For some positive integer k, desing a data structure that supports the following two operations: Insert(x), which inserts a new item x into the data structure, and extractkthSmallest(), which removes and returns the kth smallest item currently in the data structure. You may assume extract is never called if the number of items n is less than k. Insert must run in O(log n) time and extractkthSmallest must run in O(log n) time(note that O(k*logn) is easy to achieve but this is not fast enough for the extract routine. C++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
