Find an algorithm in RBTREE in O(logn)?

You can store an extra value in each node of the tree, let's call it delta. You add delta of a node to keys stored in all its descendant to get the actual keys. So, to get the actual value of a key in a particular node, you sum all deltas from the root to that node and add this sum to the stored key.

You can store an extra value in each node of the tree, let's call it delta. You add delta of a node to keys stored in all its descendant to get the actual keys. So, to get the actual value of a key in a particular node, you sum all deltas from the root to that node and add this sum to the stored key.To do Decrease-Upto, you just change deltas of O(log n) nodes on one path from root.

You don't have to change the structure of the tree after this operation, because is doesn't change ordering of the keys.

Sounds about right. Of course you have to handle the sons appropriate. – Idan Feb 10 '10 at 14:39 Well, since the OP told in comments that "you should subtract from the keys", this sounds wrong :-) – Pavel Shved Feb 10 '10 at 14:49 @Pavel I thought people on SO knew that there are also so called “negative numbersâ€?

:-) – svick Feb 10 '10 at 21:43.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions