🤓Algorithms

In the updated version of the maTH library, we can also use sorting (currently, maybe more diverse in future) algorithms, so there is no need to write your own. It supports the following algorithms:

Algorithm
O notation (best, average, worst case)
Source

Bubble sort

O(n2)O(n^2), O(n2)O(n^2), O(n2)O(n^2)

Insertion sort

O(n)O(n), O(n2)O(n^2), O(n2)O(n^2)

Selection sort

O(n2)O(n^2), O(n2)O(n^2), O(n2)O(n^2)

Merge sort

O(nlogn)O(n log n), O(nlogn)O(n log n), O(nlogn)O(n log n)

Quicksort

O(nlogn)O(n log n), O(nlogn)O(n log n), O(n2)O(n^2)

Heap sort

O(nlogn)O(n log n), O(nlogn)O(n log n), O(nlogn)O(n log n)

Count sort

O(n+k)O(n + k), O(n+k)O(n + k), O(n+k)O(n + k)

Bucket sort

O(n+k)O(n + k), O(n)O(n), O(n2)O(n^2)

Radix sort

O(nk)O(nk), O(nk)O(nk), O(nk)O(nk)

Last updated