reading-notes

Big O Notation

*Big O is used in Computer Science to describe the performance or complexity of an algorithm ,specifically its describes the worst-case scenario, and can be used to describe the execution time required or the space used by an algorithm.*

1.O(n): describes an algorithm that will always execute in the same time regardless of the size of the input data set.

2.O(n): describes an algorithm whose performance will grow linearly with the size of the input data set.

3.O(n^2): describes an algorithm whose performance is directly proportional to the square of the size of the input data set. This is common with algorithms that involve nested iterations.

3 nested loop -> O(n^3)

4 nested loop -> O(n^4)..etc

4.O(2^n):denotes an algorithm whose growth doubles with each addition to the input data set.(like Fibonacci ).

5.O(log n):iterative halving of data sets described in the binary search example produces a growth curve that peaks at the beginning and slowly flattens out as the size of the data sets increase. image