Question: Suppose we wish to support a new method countRange(k 1 , k 2 ) that determines how many keys of a sorted map fall in
Suppose we wish to support a new method countRange(k1, k2) that determines how many keys of a sorted map fall in the specified range. We could clearly implement this in O(s + h) time by adapting our approach to subMap. Describe how to modify the search-tree structure to support O(h) worst-case time for countRange.
Step by Step Solution
3.39 Rating (174 Votes )
There are 3 Steps involved in it
For each node of the tree maintain the size of the corresponding subtree defined as the number of in... View full answer
Get step-by-step solutions from verified subject matter experts
