Welcome to the Sorting Algorithms Playground! Here, you can explore different sorting algorithms and have some laughs along the way.
- Time Complexity:
- Best Case: O(n)
- Worst Case: O(n^2)
- Time Complexity:
- Best Case: O(n log n)
- Worst Case: O(n log n)
- Time Complexity:
- Best Case: O(n log n)
- Worst Case: O(n^2)
- Time Complexity:
- Best Case: O(nk)
- Worst Case: O(nk)
- Time Complexity:
- Best Case: O(n)
- Worst Case: O(n^2)
- Time Complexity:
- Best Case: O(n^2)
- Worst Case: O(n^2)
Let's take an example list [5, 3, 9, 1, 4, 8, 6] and measure the execution time for each algorithm:
- Bubble Sort: O(n^2) - Can be slow for large datasets.
- Merge Sort: O(n log n) - Efficient for large datasets.
- Quick Sort: O(n log n) - Efficient for large datasets, but worst-case scenario exists.
- Radix Sort (LSD): O(nk) - Efficient for integers with a fixed number of digits.
- Insertion Sort: O(n^2) - Simple, but less efficient for large datasets.
- Selection Sort: O(n^2) - Simple, but less efficient for large datasets.
Feel free to explore and have fun with these sorting algorithms! 🚀