Big O Notation


It describes how the performance of an algorithm scales with the size of the problem.

may be time to execute or amount of memory.

Size must be a quantitative measure of the scale of the problem. For example:

  • Number of items to sort.
  • Number of nodes in a graph.

An everyday example would be n people shaking hands in a room where the number of handshakes is and time to shake hands is .

Performance Families

5067FFC5-4A77-4CF9-A02B-8E0619F149B9

Screenshot 2022-10-24 at 17.15.36

Classifications ordered by decreasing efficiency:

  • Constant: O(1)
  • Logarithmic: O()
  • Sublinear: O() for d < 1
  • Linear: O(n)
  • Linearithmic: O()
  • Quadratic: O()
  • Exponential: O()