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

Method __init__

data_structures/heap/randomized_heap.py:99–109  ·  view source on GitHub ↗

>>> rh = RandomizedHeap([3, 1, 3, 7]) >>> rh.to_sorted_list() [1, 3, 3, 7]

(self, data: Iterable[T] | None = ())

Source from the content-addressed store, hash-verified

97 """
98
99 def __init__(self, data: Iterable[T] | None = ()) -> None:
100 """
101 >>> rh = RandomizedHeap([3, 1, 3, 7])
102 >>> rh.to_sorted_list()
103 [1, 3, 3, 7]
104 """
105 self._root: RandomizedHeapNode[T] | None = None
106
107 if data:
108 for item in data:
109 self.insert(item)
110
111 def insert(self, value: T) -> None:
112 """

Callers

nothing calls this directly

Calls 1

insertMethod · 0.95

Tested by

no test coverage detected