One way is to split the heap into elements on one side and organizations on the other.
For full functionality, you need two relationships: a) If the heap is located (for example, Root), find the Element located there. b) Given the element, find its location of the heap.
The second is very simple: add the value "location" (most likely, the index in the array based on the array), which is updated every time the item is moved to the heap.
The first is also simple: instead of storing elements, you simply save a bunch of pointers to Elements (or array indices). Now, given the location (e.g. Root), you can find the element located there by dereferencing it (or accessing the vector).
source share