I've been asked a question about B+ Tree.
The question is: Suppose we have object of the following type:
class Obj {
private:
int value;
int key;
public:
Obj(int uniq_key , int value)
}
and I am creating a Generic B+ tree which will sort objects in it leafs nodes by keys and not by values. (The keys are unique values aren't) Now I want to return the key of a node containes Maximum value within a range of keys. For Example:
If I have the following objects inserted in my B+ tree:
Obj a(1,10) , Obj(2,5) , Obj(3,0)
Then by calling this method I will get a return value : 1
I thought of having an extra rank tree with the same data stored in it and a pointer from a leaf node in the B+ tree to it's equivalent node in the rank tree but I think that there is a solution involves adding extra data in the nodes in the B+ tree which can solve this issue.
p.s. I don't know if this post is duplicated - I couldn't find anything else answering this kind of question.
Thank you, Michael