What is BIG O notation ?
Mayank Kumar
Posted on June 28, 2021
What is Big O notation ?
No No, I am not talking about this Big O ๐๐
So in the field of programming, One of the most important things that you have to know is that how to make your code efficient, and by efficient I mean readable and scalable!
To measure how good a code is we use the BIG O NOTATION
What is Big O notation ?
Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. Big O is a member of a family of notations invented by Paul Bachmann, Edmund Landau, and others collectively called BachmannโLandau notation or asymptotic notation.
As in the given figure, there are a total of 7 types of Big O notations:
1) O(1) Constant- no loops
2) O(log N) Logarithmic- usually searching algorithms have log n
if they are sorted (Binary Search)
3) O(n) Linear- for loops, while loops through n items
4) O(n log(n)) Log-Linear- usually sorting operations
5) O(n^2) Quadratic- every element in a collection needs to be compared to every other element. Two
nested loops
6) O(2^n) Exponential- recursive algorithms that solve a problem of size N
7) O(n!) Factorial- you are adding a loop for every element
Mayank@mayankthakurrr12:26 PM - 27 Jun 2021
As given in the graph the best notation to use is the O(1) or O(log n) and on the other hand the worst one to use is O(n!)
As a Developer, you need to be able to find which notation will save you the best amount of time as well as be readable to other developers. If you are able to do this you will be a superstar at your company !!!!
Happy Coding ๐
Posted on June 28, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.