Skip to content

Latest commit

 

History

History
80 lines (64 loc) · 4.86 KB

Class15.md

File metadata and controls

80 lines (64 loc) · 4.86 KB

Class 15: Friday, April 21 – Sorting Algorithms Recap

Topics:

Comparison Sorting Algorithm Complexity

Algorithm Best Time Average Time Worst Time Worst 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
Introsort Ω(n log(n)) Θ(n log(n)) O(n log(n)) O(log(n)) hybrid, in-place
Timsort Ω(n) Θ(n log(n)) O(n log(n)) O(n) hybrid, stable, adaptive

Integer Sorting Algorithm Complexity

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

Resources:

Project: