Median Search Tree

If the sorted array of all the values in the set is {ai} n

i=1, let t = n/2, then the median 2k values are

{atk+1, · · · , at+k}.

Barbara has got a set of values with size of 2k initially. Barbara wants to do m operations on it. Each

operation belongs to the following 3 types:

  • 1 w: insert a value w.
  • 2: output all the median 2k values, i.e. atk+p, 1 p 2k.
  • 3 p: delete the p-th value among median 2k values, i.e. atk+p.

We guarantee that all the values will be distinct and the size of the set is always at least 2k.

Leave a Reply

Your email address will not be published. Required fields are marked *