Sorting Algorithms
Bubble Sort
Definition:
Repeatedly swaps adjacent elements if they are in the wrong order.
1 2 3 4 5 6 7 8 9 10 11 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity:
Selection Sort
Definition:
Repeatedly selects the minimum element and moves it to the sorted portion of the array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity:
Insertion Sort
Definition:
Builds the final sorted array one item at a time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity:
Merge Sort
Definition:
Divides the array into halves, sorts them and merges the sorted halves.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity:
Quick Sort
Definition:
Picks a pivot and partitions the array such that elements less than pivot are left, greater are right.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity:
Heap Sort
Definition:
Builds a max heap and repeatedly extracts the maximum element.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity:
Radix Sort
Definition:
Sorts numbers digit by digit starting from least significant digit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity:
Bucket Sort
Definition:
Divides elements into buckets and sorts each bucket individually.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity:
Counting Sort
Definition:
Counts the occurrences of each element and places them in the correct sorted position using a count array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Time Complexity:
- Big O:
- Omega:
- Theta:
Space Complexity: