Question: Consider a binary search tree where every item consists of key and data pair. Both key and data are positive integers. Now, lets say we

Consider a binary search tree where every item consists of key and data pair. Both key and data are positive integers. Now, lets say we store an additional field called mindata in every node of the tree. This field x.mindata stores the minimum of all data values stored at all nodes in the subtree of x. Show how can this field be maintained during rotation. You need to write recalc mindata(x) for this. Now, use this field to answer Range Minimum Query in O(logn). RangeMin(Node *root, int k1, int k2) returns the minimum data value across all the nodes whose key values fall within the interval [k1,k2].

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!