Study smarter with Fiveable
Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.
Sorting algorithms are essential for organizing data efficiently. Understanding their time complexities helps in choosing the right algorithm for different scenarios, especially when dealing with large datasets. This guide covers various sorting methods and their performance characteristics.
Bubble Sort: O(n^2)
Selection Sort: O(n^2)
Insertion Sort: O(n^2)
Merge Sort: O(n log n)
Quick Sort: O(n log n) average, O(n^2) worst case
Heap Sort: O(n log n)
Counting Sort: O(n + k)
Radix Sort: O(d(n + k))
Bucket Sort: O(n + k)
Time complexity comparison between algorithms