Package-level declarations

Functions

Link copied to clipboard
fun <T : Comparable<T>> bogoSort(list: MutableList<T>)

Bogo sort is a very inefficient sorting algorithm. Principle: Shuffle the list until it is sorted.

Link copied to clipboard

Worst complexity: n^2 Average complexity: n^2 Best complexity: n Space complexity: 1 Method: Exchanging Stable: Yes

Link copied to clipboard
fun <T : Comparable<T>> MutableList<T>.bubbleSort(showPasses: Boolean = false)
Link copied to clipboard
fun Int.digit(atPosition: Int): Int?
Link copied to clipboard
fun Int.digits(): Int
Link copied to clipboard
fun <T> Array<T>.heapfy(comparator: Comparator<T>)
Link copied to clipboard
fun <T : Comparable<T>> heapSort(list: MutableList<T>)
Link copied to clipboard
fun <T> Array<T>.heapSort(comparator: Comparator<T>)
Link copied to clipboard

Worst complexity: n^2 Average complexity: n^2 Best complexity: n Space complexity: 1 Method: Insertion Stable: Yes

Link copied to clipboard
fun <T : Comparable<T>> MutableList<T>.insertionSort(showPasses: Boolean = false)
Link copied to clipboard
Link copied to clipboard
fun <T : Comparable<T>> merge(first: Iterable<T>, second: Iterable<T>): Iterable<T>
Link copied to clipboard
fun mergeInsertionSort(list: MutableList<Int>, insertionThreshold: Int = 8)

Merge-Insertion sort is a sorting algorithm using the principle that for smaller sets of data, insertion sort is more efficient than merge sort. It uses a threshold. If the list's size is below the threshold, insertion sort will be used.

Link copied to clipboard
fun <T : Comparable<T>> List<T>.mergeSort(): List<T>
Link copied to clipboard

Merge sort is an efficient algorithm for sorting lists of data. Principle: Split the list in half until it is only 2 elements long, then sort those lists. After sorting those small lists, start merging them together. For instance, having 1 3 and 2 5, by merging we would get 1 2 3 5.

Link copied to clipboard

To sort a list, this method calls mergeSortSentinel with start = 0 and end = the index of the last element in the list.

Link copied to clipboard
Link copied to clipboard

Selection sort is an inefficient* primitive sorting algorithm. Principle: Go through the list and find the smallest element in the list. After it was found, swap the element with the element on Nth place in the list, where N is the number of iterations that was already done.

Link copied to clipboard
fun <T : Comparable<T>> MutableList<T>.selectionSort(showPasses: Boolean = false)
Link copied to clipboard
fun <T> Array<T>.shiftDown(index: Int, upTo: Int, comparator: Comparator<T>)