MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / heapify

Function heapify

Python/Sorting-Techniques/heapSort.py:1–15  ·  view source on GitHub ↗
(arr, N, i)

Source from the content-addressed store, hash-verified

1def heapify(arr, N, i):
2 largest = i
3 l = 2 * i + 1
4 r = 2 * i + 2
5
6 if l < N and arr[largest] < arr[l]:
7 largest = l
8
9 if r < N and arr[largest] < arr[r]:
10 largest = r
11
12 if largest != i:
13 arr[i], arr[largest] = arr[largest], arr[i]
14
15 heapify(arr, N, largest)
16
17def heapSort(arr):
18 N = len(arr)

Callers 1

heapSortFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected