Skip to content

Latest commit

 

History

History
93 lines (78 loc) · 6.41 KB

Class17.md

File metadata and controls

93 lines (78 loc) · 6.41 KB

Class 17: Sorting Algorithms Comparison

Topics

Comparison Sorting Algorithm Complexity

Algorithm Best Time Average Time Worst Time Space Features
Bubble sort Ω(n) Θ(n2) O(n2) O(1) stable, in-place, adaptive
Selection sort Ω(n2) Θ(n2) O(n2) O(1) stable, in-place
Insertion sort Ω(n) Θ(n2) O(n2) O(1) stable, in-place, adaptive
Tree sort Ω(n⋅log n) Θ(n⋅log n) O(n2) O(n)
Quick sort Ω(n⋅log n) Θ(n⋅log n) O(n2) O(log n) in-place
Merge sort Ω(n⋅log n) Θ(n⋅log n) O(n⋅log n) O(n) stable
Heap sort Ω(n⋅log n) Θ(n⋅log n) O(n⋅log n) O(1) in-place
Intro sort Ω(n⋅log n) Θ(n⋅log n) O(n⋅log n) O(log n) in-place, hybrid
Tim sort Ω(n) Θ(n⋅log n) O(n⋅log n) O(n) stable, adaptive, hybrid

Integer Sorting Algorithm Complexity

Algorithm Best Time Average Time Worst Time Space
Counting sort Ω(n+k) Θ(n+k) O(n+k) O(k)
Bucket sort Ω(n+k) Θ(n+k) O(n2) O(n)
Radix sort Ω(n⋅k) Θ(n⋅k) O(n⋅k) O(n+k)

Resources

Project