Goal: Understand how the runtime of an algorithm is affected by an increasing number of elements.
- Analyze the worst case performance of the algorithm, i.e. Big O
- Add steps in order (+); multiply nested steps (*)
- Different inputs should have different variables, e.g. O(a+b)
- Remove constants
- Drop non-dominants
O(1) – Constant O(log n) – Logarithmic O(n) – Linear
O(n * log n) – Log Linear
O(n^2) – Quadratic O(2^n) – Exponential O(n!) – Factorial
Every time you are using a tree or converting something into a tree, consider recursion
- Divided into a number of subproblems that are smaller instances of the same problem
- Each instance of the subproblem is identical in nature
- The solutions of each subproblem can be combined to solve the problem at hand