RecursiveBubbleSort

Recursive Bubble Sort.

Bubble Sort implemented using recursion.

Time complexity:

  • Best: O(n)

  • Average: O(n²)

  • Worst: O(n²)

Space complexity:

  • O(n) due to recursion stack

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 a comparator.