Data-Structures-and-Algorithms-in-JS

Time complexity

O(1) - does not change with respect to input space. Hence, O(1) is referred to as being constant time

O(n) - ) is linear time and applies to algorithms that must do n operations in the worst-case scenario.

Logarithm O(logn) - An Inverse of exponentiation. log2(8)=3 --------> 2^3=8 log2(value) --------> 2^exponent = value - The logarithm of a number roughly measures the number of times you can divide that number by 2 before you get a value that's less than or equal to one. - Certain searching algorithms have logarithmic time complexity. - Efficient algorithms involve logarithms - Recursion sometimes involves logarithmic space complexity.