with its left child( , )at index of the listthen swapped with its right child( , )at index of the list in the final configurationthe locator instances for all affected elements have been modified to reflect their new location it is important to emphasize that the locator instances have not changed identity the user' token referenceportrayed in figures and continues to reference the same instancewe have simply changed the third field of that instanceand we have changed where that instance is referenced within the list sequence with this new representationproviding the additional support for the adaptable priority queue adt is rather straightforward when locator instance is sent as parameter to update or removewe may rely on the third field of that structure to designate where the element resides in the heap with that knowledgethe update of key may simply require an up-heap or down-heap bubbling step to reestablish the heap-order property (the complete binary tree property remains intact to implement the removal of an arbitrary elementwe move the element at the last position to the vacated locationand again perform an appropriate bubbling step to satisfy the heap-order property python implementation code fragments and present python implementation of an adaptable priority queueas subclass of the heappriorityqueue class from section our modifications to the original class are relatively minor we define public locator class that inherits from the nonpublic item class and augments it with an additional index field we make it public class because we will be using locators as return values and parametershoweverthe public interface for the locator class does not include any other functionality for the user to update locators during the flow of our heap operationswe rely on an intentional design decision that our original class uses nonpublic swap method for all data movement we override that utility to execute the additional step of updating the stored indices within the two swapped locator instances we provide new bubble utility that manages the reinstatement of the heaporder property when key has changed at an arbitrary position within the heapeither due to key updateor the blind replacement of removed element with the item from the last position of the tree the bubble utility determines whether to apply up-heap or down-heap bubblingdepending on whether the given location has parent with smaller key (if an updated key coincidentally remains valid for its current locationwe technically call downheap but no swaps result the public methods are provided in code fragment the existing add method is overriddenboth to make use of locator instance rather than an item instance for storage of the new elementand to return the locator to the caller the remainder of that method is similar to the originalwith the management of locator indices enacted by the use of the new version of swap there is no reason to over