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

Method _heapify_up

data_structures/heap/heap_generic.py:65–70  ·  view source on GitHub ↗

Fixes the heap in upward direction of given index

(self, index: int)

Source from the content-addressed store, hash-verified

63 return valid_parent
64
65 def _heapify_up(self, index: int) -> None:
66 """Fixes the heap in upward direction of given index"""
67 parent = self._parent(index)
68 while parent is not None and not self._cmp(index, parent):
69 self._swap(index, parent)
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"""

Callers 3

update_itemMethod · 0.95
delete_itemMethod · 0.95
insert_itemMethod · 0.95

Calls 3

_parentMethod · 0.95
_cmpMethod · 0.95
_swapMethod · 0.95

Tested by

no test coverage detected