Math Fundamentals18 sections · 814 units
Open in Course

O(n²) - Quadratic Time

(Nested loops)

An algorithm is O(n²) if it processes each pair of elements. Two nested loops that both run n times give quadratic complexity.

Doubling input size quadruples runtime. This scales poorly. An array of 1000 elements means 1 million operations.

Bubble sort, selection sort, and naive duplicate checking are O(n²).