- big O is used to describe the performance of an algorithm. it determines how scalable an algorithm is. ==> we want to figure out how the algorithm slows down as size of arguments grows larger.
run time complexity
O(1) — Constant Time:
O(log n) — Logarithmic Time: The number of steps it takes to accomplish a task are decreased by some factor with each step.
O(n) — Linear Time: The number of of steps required are directly related (1 to 1).
O(n²) — Quadratic Time: The number of steps it takes to accomplish a task is square of n.
O(2^N) — Exponential Time: a algorithm by exponential time complexity is not scalabe at all and become very slow.\
the logarithmic growth slows down as the input growths. the opposite of logarithmic growth is exponential growth.\
in addition to time complexity
, there is another concept called space complexity
.
Arrays
- arrays are the simplest data structure which is used to store list of items.