🧮Big O Notation
Also known as Big O, Big-O, O(n), Asymptotic Notation
How fast an algorithm's work grows when its input grows.
Think of it like
Think of it like a walk. If the road gets twice as long, how much longer is the walk?
Example
Lucy's search checks every name, which is O(n). For 1,000,000 names it may take 1,000,000 checks; a binary search needs about 20.
Why it matters
It lets you compare algorithms before you write them. A bad growth shape hurts more as data gets bigger.
Definition
Common mistake
Key takeaways
- 1Growth, not speed. How work rises with size.
- 2Common shapes. O(1), O(log n), O(n), O(n²).
- 3Worst case usually. Unless it says otherwise.