stella v0.6.0 Insertionsort
Documentation for Insertion sort
algorithm. All important
informations about counting sort you can find at
Wikipedia page.
Annotations
- n - number of elements in list
Link to this section Summary
Functions
Sort list
Link to this section Functions
Link to this function
run(unsorted)
Specs
Sort list
- Worst-case performance: O(n^2)
- Average performance: O(n^2)
- Best-case performance: O(n) - for already sorted or empty lists
Examples
iex> Insertionsort.run([4, 1, 3, 2])
[1, 2, 3, 4]
iex> Insertionsort.run([-7, 0, 0, -2, -3, 5, 2])
[-7, -3, -2, 0, 0, 2, 5]