MCPcopy
hub / github.com/hustcc/JS-Sorting-Algorithm / heapify

Function heapify

src/pythonSortTest.py:134–145  ·  view source on GitHub ↗
(arr, i)

Source from the content-addressed store, hash-verified

132
133
134def heapify(arr, i):
135 left = 2 * i + 1
136 right = 2 * i + 2
137 largest = i
138 if left < arrLen and arr[left] > arr[largest]:
139 largest = left
140 if right < arrLen and arr[right] > arr[largest]:
141 largest = right
142
143 if largest != i:
144 swap(arr, i, largest)
145 heapify(arr, largest)
146
147
148def swap(arr, i, j):

Callers 2

buildMaxHeapFunction · 0.70
heapSortFunction · 0.70

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected