AlgoViz

O(n) linear time

easy 13 min

O(n) means the work grows in direct proportion to the input: double the data, double the time.

Where it shows up

The same pattern appears across everyday software.

  • Searching logs

    When a service misbehaves, engineers run grep or a log search over the day's logs. With no index, the tool reads every line once, so a log twice as large takes twice as long to search.

  • Database full table scans

    A query that filters on a column without an index makes the database read every row of the table. Query plans call this a sequential or full scan, and it is the usual reason a query slows down as a table grows. Adding an index turns it into an O(log n) lookup.

  • File checksums

    Download pages publish SHA-256 checksums so you can verify a file. Computing one reads every byte of the file exactly once, so hashing a 2 GB file takes about twice as long as a 1 GB file.

  • Sensor dashboards

    A monitoring dashboard showing today's minimum, maximum and average temperature keeps running values and updates them with each new reading: constant work per reading, linear over the day.

  • Removing duplicate sign-ups

    Cleaning a mailing list of repeated email addresses with a hash set takes one pass. Comparing every address against every other would be O(n²) and grind to a halt on a million addresses.