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

Method insert

data_structures/heap/max_heap.py:32–36  ·  view source on GitHub ↗

Insert new element

(self, value: int)

Source from the content-addressed store, hash-verified

30 i //= 2
31
32 def insert(self, value: int) -> None:
33 """Insert new element"""
34 self.__heap.append(value)
35 self.__size += 1
36 self.__swap_up(self.__size)
37
38 def __swap_down(self, i: int) -> None:
39 """Swap the element down"""

Callers 1

max_heap.pyFile · 0.45

Calls 2

__swap_upMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected