Handbooks / Data Structures & Algorithms / Chapter 5
Sorting and Searching
7 pages · ~5 min✓ Reviewed
Builds on Linked Lists, Stacks and Queues. Next up: Trees and Graphs.
Big-O and Sorting Mental Model
1. Reading Big-O
- Drop constants and lower terms:
3n² + 5n + 2is O(n²) - An upper bound on growth as n grows
- State which case it bounds: best, average or worst
- O(1)
- O(log n)
- O(n)
- O(n log n)
- O(n²)
- O(2ⁿ)
- O(n!)