小于 1 分钟
Home > @hz-9/algorithm > bubbleSortBase
bubbleSortBase() function
Bubble sort algorithm.
冒泡排序。
Time complexity: O(n^2)
Time complexity badest case: O(n^2)
Time complexity goodest case: O(n)
Space complexity: O(1)
Signature:
bubbleSortBase: <T>(list: T[], compareFu?: CompareFn<T>) => T[]Parameters
Parameter | Type | Description |
|---|---|---|
list | T[] | The array to be sorted. |
compareFu | CompareFn<T> | (Optional) The comparison function used to determine the order of the elements. |
Returns:
T[]
- The sorted array. (Is original array)