ShellSort

Shell Sort.

Generalization of insertion sort that allows exchanges of elements far apart using a gap sequence.

Time complexity:

  • Depends on gap sequence

  • Average: around O(n log² n)

  • Worst: O(n²)

Space complexity:

  • O(1)

Functions

Link copied to clipboard
fun <T : Comparable<T>> sort(array: Array<T>)

Sorts the array using natural ordering.

fun <T> sort(array: Array<T>, comparator: Comparator<T>)

Sorts the array using the provided comparator.