Sorting Algorithms, Sorting, Merge Sort, Quick Sort, Algorithms.
j--; } arr[j + 1] = current; } return arr; } This method is particularly efficient if the array is already mostly sorted, so we will have the best-case time complexity of O(n) under such conditions. However, in the worst case, its time complexity regresses to O(n²). The space complexity remains