Skip to content

Latest commit

 

History

History
55 lines (35 loc) · 1.45 KB

Complexity.md

File metadata and controls

55 lines (35 loc) · 1.45 KB

Table of Contents

Complexity Analysis

The process of determining how efficient the algorithm is. Complexity analysis involves both Time and Space Complexities of an Algorithm.

It's needed to determine the better algorithm for the purpose.

Types

It is classified into 3 types.

  1. Best Case - Big Omega
  2. Medium Case - Big Theta
  3. Worst Case - Big O

Logarithm

In Maths log means log10, in Computer science log2.

  • log2 16 = ?; 24 = 16; log2 16 = 4;

  • log2 8 = ?; 23 = 8; log2 8 = 3;

  • log2 12 =?; 23 = 8; 24 = 16; log2 12 = 3.5

Order of Complexity from fastest to slowest

Very Important concept to understand before going deep inside Time and Space complexity.

  1. Constant: O(1)
  2. Logarithmic: O(log(n))
  3. Linear: O(n)
  4. Log-Linear: O(nlog(n))
  5. Quadratic: O(n2)
  6. Cubic: O(n3)
  7. Exponential: O(2n)
  8. Factorial: O(n!)

Complexity Chart

Big O Complexity Chart