
Week 2, Monday
January 12, 2026
For \(T(n)\), the running time of an algorithm on input of size \(n\)…
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 3 | 7 | 2 | 9 | 1 | 8 | 4 | 6 | 5 | 2 | 7 | 3 |
For \(n = 6\):
What are the values of i and j for the 17th element counted?
What are the values of i and j for the 32nd element counted?
What’s the worst-case running time?

For \(n = 6\):
What are the values of i and j for the 4th element counted?
What are the values of i and j for the 12th element counted?
What’s the worst-case running time?

\(O(g(n))\) is the set of all functions \(f(n)\) satisfying the definition.
\[O(n) = \{f(n) : \exists c > 0, n_0 \geq 0 \text{ such that } f(n) \leq c \cdot n \text{ for all } n \geq n_0\}\]
\[O(1) \subset O(\log n) \subset O(n) \subset O(n \log n) \subset O(n^2) \subset O(2^n)\]
Each class contains all the ones to its left.
We write: \(\quad 4n + 2 = O(n)\)
We mean: \(\quad 4n + 2 \in O(n)\)