You can store additional value in each node of the tree, letβs call it delta. You add delta from node to the keys stored in your entire descendant to get the actual keys. Thus, in order to get the actual key value in a specific node, you sum all the delta from the root to this node and add this amount to the saved key.
To make Decrease-Upto , you simply change the deltas of the O (log n) nodes along one path from root.
You do not need to change the structure of the tree after this operation, because it does not change the order of the keys.
svick source share