Question: /10 points/ Let T be a binary search tree with n nodes and height (log n), where each node x of T stores a r.key
/10 points/ Let T be a binary search tree with n nodes and height (log n), where each node x of T stores a r.key value (which is a real number), as well as an augmented value r.sum as introduced above in Problem 7 Describe an algorithm QueryPartialSum(T. ki. k2) which answers the following query: Given two ranks ki and k2, return the total sum of all keys in T whose rank falls in k.k2 For example, QueryPartialSum(T, 1, n) should return the sum of all keys stored in T, and QueryPartialSum(T 1, k) returns the sum of smallest k keys stored in T You are NOT allowed to use extra data structure to aid you (say, build another array of size O(n)). You can only use the current tree structure- but you may augment it if you need to (although there are solutions without needing to do that). Give the time complexity analysis of your algorithm. Slower but correct algorithm will receive partial credits
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
