A type of data structure very common and very used is the Heap
. This data structure is characterized by a relationship imposed upon its nodes: if <
is a relationship and node
is a node, then node < node.child
for all the children of the node
.
But what happens when you need to change the relationship?
The brute-force way is simply to extract all elements from the Heap
and add them to another Heap
having the desired relationship: usually that takes O(n log(n))
time. Does it exist a Heap
that allow to change its relationship in a faster way, possibly with an in-place algorithm?