Skip to content
Ultimate Algorithm

Big O Notation

1. Big O Notation :dart:

When you study Algorithms, you will see a lot of notations like O(n), O(nlogn) and such. No need to be lost! :) This is just a mark of how much the time/space cost will approximately take for the given algorithm. n refers to the size of the input.

Here are some examples of Big O Notation:

  • O(1): The cost is irrelevant of the input size n
  • O(n): The cost is linear of the input size n
  • O(nlogn): Oh wow, The cost increases in proportion to nlogn of the input size n
  • O(n^2): Oh… The cost increases in proportion to n^2 of the input size n
  • O(n!): Omg!! The cost increases in proportion to factorial of the input size n!