What is a location-aware entry, and why does an adaptable priority queue need it?
A location-aware entry knows where it is stored inside the data structure, for example a reference to its list node or its index in the heap array. Given the handle e, the queue can reach e's position in $O(1)$ instead of searching for it, which keeps remove(e) and replaceKey(e, k) fast.
Without location awareness, remove(e) and replaceKey(e, k) must first find e. Neither a list nor a heap supports search by entry (a heap does not even order siblings), so that costs $O(n)$ and wipes out whatever the underlying structure gained.
So each entry carries a back-reference to its position:
- In a linked list: a reference to the list node holding it. Unlinking a node from a doubly linked list is $O(1)$.
- In an array-based heap: the array index where the entry currently sits.
The catch: the location must stay true. Whenever the structure moves an entry, it must update the entry's stored location at the same moment. In a heap that means every swap during upheap or downheap updates the indices of both entries involved. Forget that once, and a later remove(e) operates on the wrong slot.
It is a classic data-structure trade-off: a little extra memory per entry and a little extra work per swap buy constant-time access to any entry. Back-references like these show up in many high-performance structures; graph implementations use the same idea for their vertices and edges.