MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / build_heap

Method build_heap

data_structures/heap/min_heap.py:54–64  ·  view source on GitHub ↗
(self, array)

Source from the content-addressed store, hash-verified

52 return self.heap_dict[key]
53
54 def build_heap(self, array):
55 last_idx = len(array) - 1
56 start_from = self.get_parent_idx(last_idx)
57
58 for idx, i in enumerate(array):
59 self.idx_of_element[i] = idx
60 self.heap_dict[i.name] = i.val
61
62 for i in range(start_from, -1, -1):
63 self.sift_down(i, array)
64 return array
65
66 # this is min-heapify method
67 def sift_down(self, idx, array):

Callers 1

__init__Method · 0.95

Calls 2

get_parent_idxMethod · 0.95
sift_downMethod · 0.95

Tested by

no test coverage detected