MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / _heapify_down

Method _heapify_down

data_structures/heap/heap_generic.py:72–77  ·  view source on GitHub ↗

Fixes the heap in downward direction of given index

(self, index: int)

Source from the content-addressed store, hash-verified

70 index, parent = parent, self._parent(parent)
71
72 def _heapify_down(self, index: int) -> None:
73 """Fixes the heap in downward direction of given index"""
74 valid_parent = self._get_valid_parent(index)
75 while valid_parent != index:
76 self._swap(index, valid_parent)
77 index, valid_parent = valid_parent, self._get_valid_parent(valid_parent)
78
79 def update_item(self, item: int, item_value: int) -> None:
80 """Updates given item value in heap if present"""

Callers 2

update_itemMethod · 0.95
delete_itemMethod · 0.95

Calls 2

_get_valid_parentMethod · 0.95
_swapMethod · 0.95

Tested by

no test coverage detected