Big O Notation
What is Big O ??? Big O notation is a technique used to describe the complexity of an algorithm. It is very useful when evaluating performance wise of different algorithms doing the same task. In this post, I'm not going deep into the programming side but let's take a code snippet as an example. In this code, we are trying to add up all the natural numbers up to 100. There are two algorithms doing the same job but they perform differently. #***********************# # Method 1 n = 100 sum = 0 for i in range ( 0 , n + 1 ): sum = sum + int (i) print sum #***********************# # Method 2 print str (n * (n + 1 ) / 2 ) #***********************#