Implementation of sorting algorithms from Introduction to Algorithms (CLRS)
Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to algorithms. MIT press.
Command line tutorial for Insertion Sort:
>>> from InsertionSort import *
>>> unsorted = [1, 5, 3, -1, 0, 9, 12]
>>> test = InsertionSort(unsorted)
>>> test.sort()
[-1, 0, 1, 3, 5, 9, 12]
>>> test.swap(2, 4)
[-1, 0, 5, 3, 1, 9, 12]
>>> test.sort()
[-1, 0, 1, 3, 5, 9, 12]
>>> test.time_it()
0.000028849 seconds
Hoping to add MergeSort, Quicksort, and a brief discussion on best use-cases.
Optimistically, an example of a quantum sorting algorithm (for space complexity analysis).