In your lecture notes
The definitions. The code. The theory.
Computer science · Algorithm analysis
Asymptotic growth & loop analysis
Two full nested loops have n × n calls. Their work is Θ(n²).
Compare with the original notes
Big O gives an asymptotic upper bound. T(n) belongs to O(g(n)) if positive constants c and n₀ exist such that 0 ≤ T(n) ≤ c·g(n) for every n ≥ n₀.
A single full loop has n calls to process: for item in items: process(item) Under the constant-work assumption, its work is Theta(n). Two consecutive full loops require n + n = 2n calls and remain Theta(n). Multiplication applies to repeated nesting, not merely to having two loops in the program.
Two full nested loops have n × n calls. Their work is Θ(n²). A loop inside another loop does not automatically imply quadratic growth: the inner iteration count and its cost matter.
Read the complete source
