Deletion of Arbitrary Element from a Max HBLT in Data Structure

Data StructureAnalysis of AlgorithmsAlgorithms

Deleting Arbitrary nodes from Max or Min HBLT is not standard operation. for Priority queue or HBLT. If we want to delete a node say K from HBLT, we have to follow following rules.

  • Detach the subtree rooted at K, from the tree, and replace it with the meld of the subtrees of node K.

  • Update s values from the path from K to the root, and swap subtrees on this path as necessary to maintain the property of HBLT.

To update the s value from K to root, we need the parent pointer for each node. This operation for updating the s value to the upward nodes will stop, when we see that the s value is not changed. The changed s values, must form an ascending sequence. Because each node must be one more than the preceding one. Since the max s value is O(log n), and all s values are positive, maximum O(log n) nodes are encountered in the updating pass. Each of node take O(1) for updating the values. So overall complexity of deleting an arbitrary node is O(log n)

raja
Published on 11-Aug-2020 10:42:49
Advertisements