我在这里有一个问题,需要设计一种数据结构,对以下三个操作保证最坏情况下的时间复杂度为O(lg n):
a) Insertion: Insert the key into data structure only if it is not already there.
b) Deletion: delete the key if it is there!
c) Find kth smallest : find the ݇k-th smallest key in the data structure
我在考虑是否应该使用堆,但我对此仍没有明确的想法。
我可以很容易地在O(lg n)甚至更快的时间内获得前两部分,但不确定如何处理第c部分。
如果有人有任何想法,请分享。