Skip to content

Instantly share code, notes, and snippets.

@LasseJacobs
LasseJacobs / heapsort.py
Created March 10, 2018 14:02
Python heapsort (As descirbed in Introduction to Algorithms)
def swap(a, i, j):
a[i], a[j] = a[j], a[i]
def left(i):
return 2*i + 1
def right(i):
return 2*i + 2
def max_heapify(array, i, h_size):