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

Function heapify

Python/all sorting methods.py:149–160  ·  view source on GitHub ↗
(customList,n,i)

Source from the content-addressed store, hash-verified

147# HEAP SORT ALGORITHM
148
149def heapify(customList,n,i):
150 smallest = i
151 l = 2*i + 1
152 r = 2*i + 2
153
154 if l < n and customList[l] < customList[smallest]:
155 smallest = l
156 if r < n and customList[r] < customList[smallest]:
157 smallest=r
158 if smallest != i:
159 customList[i], customList[smallest] = customList[smallest], customList[i]
160 heapify(customList ,n ,smallest)
161
162def heapSort(customList):
163 n = len(customList)

Callers 1

heapSortFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected