Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 1.17 KB

Time Complexity: Big O.md

File metadata and controls

23 lines (18 loc) · 1.17 KB

Big O Cheat Sheet:

-Big Os-

O(1): Constant-no loops
O(log N):Logarithmic- usually searching algorithms have log n if they are sorted (Binary Search)
O(n):Linear- for loops, while loops through n items
O(n log(n)):Log Liniear- usually sorting operations
O(n^2):Quadratic- every element in a collection needs to be compared to ever other element. Two nested loops
O(2^n):Exponential- recursive algorithms that solves a problem of size N
O(n!):Factorial- you are adding a loop for every element

-Rule Book-

Rule 1: Always worst Case
Rule 2: Remove Constants
Rule 3: Different inputs should have different variables.
Rule 4: Drop Non-dominant terms