I'm trying to create some rank tree based on AVL tree with special requirements, lets assume that I have AVL tree with nodes, each node has 2 fields:
id, priority
my AVL tree is sorted by id, also I have a function:
foo(currentId, delta)
which lowers the priority of the all ids which is less or equal to currentId
by delta
this function has to work with complexity O(log n),
so my question is which additional information do I need to store to be able to pop the node with the highest priority
at any stage with complexity O(1)
(after using foo also!).
P.S.
I tried to store info about max priority in the right subtree, max priority in the left subtree, but it needs a lot of changes after foo
. It will take more than just O(log n). Thanks in advance for any good ideas or good books about Trees.