Countingsort (stella v0.7.1)

Documentation for Counting sort algorithm. All important informations about counting sort you can find at Wikipedia page.

annotations

Annotations

  • n - number of elements in list
  • range of the non-negative key values.

Link to this section Summary

Functions

Sort list

Link to this section Functions

@spec run([integer()]) :: [integer()]

Sort list

  • Normal complexity: O(n)
  • Worst complexity: O(n + k)

examples

Examples

iex> Countingsort.run([4, 1, 3, 5, 2])
[1, 2, 3, 4, 5]

iex> Countingsort.run([1, 2, 4, 3])
[1, 2, 3, 4]