B2.4.1 · Efficiency and memory
Quadratic growth · O(n²)
Python · step by step
Quadratic growth · O(n²)
Watch the number of marked operations as input size changes.
Python implementation
1visits = []23def growth_quadratic(n):4 for i in range(n):5 for j in range(n):6 visits.append([i, j])7 return len(visits) visits is an instrumentation list used only to show work. Do not count this display logging when judging the underlying algorithm’s auxiliary space. We count append events, not every Python operation.
Keep exploring
Return to the algorithm efficiency lesson →
All B2.4 animations →