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
Get step-by-step solutions from verified subject matter experts
