What I learned from each Performance

Insertion Sort

Insertion sort iterates through an array, starting from the second element, comparing each element with the sorted portion on its left, shifting larger elements to the right, and inserting the current element into its correct position. It repeats this process for next element, resulting in a sorted array.

Bogo Sort (Stupid Sort)

Bogo sort shuffles the elements of an array randomly and checks if they are sorted, repeating until the array is sorted, which gives it an average-case time complexity of O((n+1)!), making it a very slow method for sorting.

Quick Sort

Quick sort sorts an array by selecting a pivot, partitioning the array into two sub-arrays based on the pivot, and recursively sorting them. With an average time complexity of O(n log n), it’s one of the fastest sorting algorithms available.

Bubble Sort

Bubble sort repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order, iterating until no swaps are needed. Despite its simplicity, its average-case and worst-case time complexity of O(n^2) make it inefficient for large datasets.

Merge Sort

Merge sort divides the array into smaller sub-arrays, recursively sorts them, and then merges them back together in sorted order. Its efficient divide-and-conquer approach results in an average and worst-case time complexity of O(n log n), making it suitable for sorting large datasets.

Selection Sort

Selection sort iteratively selects the smallest (or largest) element from the unsorted portion of the array and swaps it with the element at the beginning of the unsorted portion. This process is repeated until the entire array is sorted, with an average and worst-case time complexity of O(n^2), making it inefficient for large datasets.