Bubble Sort
Definition:
Bubble Sort compares adjacent elements and swaps them if they are in wrong order.
Time Complexity:
Best: O(n)
Worst: O(n^2)
Average: O(n^2)
Space Complexity:
O(1)
Selection Sort
Definition:
Selection Sort finds the minimum element and places it at the beginning in every iteration.
Time Complexity:
Best: O(n^2)
Worst: O(n^2)
Average: O(n^2)
Space Complexity:
O(1)
Insertion Sort
Definition:
Insertion Sort inserts each element into its correct position in the sorted left side.
Time Complexity:
Best: O(n)
Worst: O(n^2)
Average: O(n^2)
Space Complexity:
O(1)
Merge Sort
Definition:
Merge Sort is a divide and conquer algorithm, splitting array in half, sorting them, then merging.
Time Complexity:
Best: O(n log n)
Worst: O(n log n)
Average: O(n log n)
Space Complexity:
O(n)
Quick Sort
Definition:
Quick Sort picks a pivot element and partitions the array around pivot recursively.
Time Complexity:
Best: O(n log n)
Worst: O(n^2)
Average: O(n log n)
Space Complexity:
O(log n)