Math Fundamentals18 sections · 814 units
Open in Course

O(n) - Linear Time

(One pass through data)

An algorithm is O(n) if it processes each input element a constant number of times. A single loop that visits every element is O(n).

Finding the maximum value in an array requires checking all n elements. You cannot skip any. This is O(n).

Doubling the input doubles the work. The relationship is a straight line.