----------------- Why binary search is O(log_2(n)): Every iteration, binary search halves the search space, until the search space has only one/zero items. Suppose the array size is n. To find out how many times we need to halve n by to get 1, we solve for x in the following: n ----- = 1 2^x n = 2^x x = log_2(n) ----------------- Time complexity examples: O(n^2): double input size -> algo takes four times as long triple input size -> algo takes nine times as long T(n) = n^2 T(3n) = (3n)^2 = 9n^2 = 9T(n) O(n^3): double input size -> algo take eight times as long triple input size -> algo takes 27 times as long ----------------- Exercise in appendix section: O(n^2) algorithm If input size is: - 1000 => 1.2 seconds - 2000 => 4.8 seconds - 10,000 => 120 seconds - 100,000 => 12,000 seconds => 200 minutes - 1,000,000 => 20,000 minutes