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.

Select Play or Next line to follow Python execution.

Python implementation

The highlight marks the next line to execute. Values show the state before that line.

visits = []def growth_quadratic(n):    for i in range(n):        for j in range(n):            visits.append([i, j])    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 →

All practice & resources →