Asymptotic Analysis and Growth Rates
Computer Science & Algorithms · Advanced Placement
Why growth rate matters
{{illustration:cb-growth}}
- Running time is a function of input size n. - Growth rate decides which algorithms scale.
Common classes
{{illustration:cb-classes}}
| Class | Name | Steps at n = 20 | |---|---|---| | log n | logarithmic | about 4 | | n | linear | 20 | | n log n | linearithmic | about 86 | | n² | quadratic | 400 | | 2ⁿ | exponential | 1 048 576 |
Analysing code
{{illustration:cb-analysis}}
- Loops multiply, sequential blocks add. - Keep the dominant term and drop constant factors.
Doubling experiments
{{illustration:cb-doubling}}
- Doubling n reveals the exponent empirically. - Big-O is an upper bound; Θ is a tight bound.