← Analysis of Algorithms: all 3 parts
Computer science · Free practice
Analysis of Algorithms, Part 3: Nested Loops, the Quick Way
Watch the lesson by Dr. J. Ubaldo Quevedo, then practice as many times as you want: every New button gives you a new loop or sum.
1. Watch
- Next to each line, write how many times it runs, then multiply by the passes of every loop around it.
- Outer loop: 1 + (n + 1) + n. Inner loop: n(1 + (n + 1) + n). Inner body: n · n.
- Only the fastest-growing term matters for large n: 3 + 4n + 3n² is O(n²).
2. Try it yourself
Practice as many times as you want. Every New button builds a new loop or sum. It's free, and you don't need an account.
Correct so far: 0