sorts.heap_sort¶
This is a pure Python implementation of the heap sort algorithm.
For doctests run following command: python -m doctest -v heap_sort.py or python3 -m doctest -v heap_sort.py
For manual testing run: python heap_sort.py
Attributes¶
Functions¶
|
Pure implementation of the heap sort algorithm in Python |
|
Module Contents¶
- sorts.heap_sort.heap_sort(unsorted)¶
Pure implementation of the heap sort algorithm in Python :param collection: some mutable ordered collection with heterogeneous comparable items inside :return: the same collection ordered by ascending
Examples: >>> heap_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5]
>>> heap_sort([]) []
>>> heap_sort([-2, -5, -45]) [-45, -5, -2]
- sorts.heap_sort.heapify(unsorted, index, heap_size)¶
- sorts.heap_sort.user_input¶