Bubblesort (stella v0.7.1)

Documentation for Bubble sort algorithm. All important informations about counting sort you can find on Wikipedia page.

annotations

Annotations

  • n - number of elements in list

Link to this section Summary

Functions

Sort list

Link to this section Functions

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

Sort list

  • Best-case performance: O(n)
  • Average performance: O(n^2)
  • Worst-case performance: O(n^2)

examples

Examples

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

iex> Bubblesort.run([-2.0, 0, 4, 1, 3, 2])
[-2.0, 0, 1, 2, 3, 4]

iex> Bubblesort.run([-2.0, 0.0001, 0.00001, 1, 3, 2])
[-2.0, 0.00001, 0.0001, 1, 2, 3]