Difference between revisions of "TADM2E 3.7"
From Algorithm Wiki
(Recovering wiki) |
(Added handling deletion of the maximum) |
||
Line 1: | Line 1: | ||
− | Store two values, the maximum and minimum. These need to be checked and potentially updated on every delete. If | + | Store two values, the maximum and minimum. These need to be checked and potentially updated on every delete. If the minimum is being deleted, call the successor, update the minimum and delete the old item. Similarly, if the maximum is being deleted, call the predecessor, update the maximum and delete the old item. On insert, compare the new item to min/max, if it replaces either one update the min/max accordingly. |
Latest revision as of 09:25, 9 May 2018
Store two values, the maximum and minimum. These need to be checked and potentially updated on every delete. If the minimum is being deleted, call the successor, update the minimum and delete the old item. Similarly, if the maximum is being deleted, call the predecessor, update the maximum and delete the old item. On insert, compare the new item to min/max, if it replaces either one update the min/max accordingly.