Big O

A standardize way to measure how an algorithm’s performance changes as the amount of data it receives increases.

  1. It measures growth with respect to the input. If algorithm receives N elements, as input how many steps will it take to finish?
  2. Constants are dropped because they are not concerned with the size of the input.
  3. It generally refers to the worst-case scenario.

Time complexities

NotationNameDescription
O(1)ConstantDoesn’t increase when the amount of data changes
O(n)LinearIncreases one step each time the data has one additional element
O(log n)LogarithmicIncreases one step each time the data is doubled
O(n^2)Quadratic

Resources