Algorithm | Time Complexity | ||
Finding all subsets of a set | O(2^n) | ||
Finding all permutations of a string | O(n!) | ||
Sorting using merge sort | O(n log(n)) | ||
Iterating over a matrix of size n by m | O(nm) |
IMPORTANT
Complexities ordered from smallest to largest:-
Constant Time | O(1) |
Logarithmic Time | O(log(n)) |
Linear Time | O(n) |
Linearithmic Time | O(n logn) |
Quadric Time | O(n^2) |
Cubic Time | O(n^3) |
Exponential Time | O(b^n), b>1 |
Factorial Time | O(n!) |
O(n+c) | O(n) |
O(cn) | O(n), c>0 |
Comments
Post a Comment