O(n)

Linear Time

Fine

Look at every element once. Grows evenly with input.

Mental model

Checking every seat in a cinema row to find your friend. 10 seats → up to 10 checks. 100 seats → up to 100 checks. Time grows in a straight line proportional to the data.

Interactive Visualisation
🪑  Checking every seat in a cinema row to find your friend. You start at seat 1, check it, move to seat 2, and so on. If your friend is in seat 8, you do 8 checks. 100 seats → up to 100 checks. Time grows directly with the data.

Looking for: element #1 (hidden at index 0)

1
2
3
4
5
6
7
8
9
10
11
12

Operations grow 1-to-1 with n

n=55
n=1010
n=2020
n=5050
n=100100

How it scales

n = 10

10 ops

n = 100

100 ops

n = 1,000

1,000 ops

n = 1,000,000

1,000,000 ops

Previous

O(log n)Logarithmic Time

Next

O(n log n)Linearithmic Time