Def algorithm - The system or plan you use to arrive at a solution
- As the size of the problem gets bigger, the cost might grow quickly/slowly/not at all.
- Time complexity - Mathematical comparison between different plans, or algorithm.
- Cheat sheet- bigocheatsheet.com - An approximation of time complexity, describes worst-case performance for large n.
Name | Big-O Notation | Operations for n items | Approach | Example ---|--- Constant | O(1) | 1 | Compare first & last numbers | Array lookup, hash table insertion Logarithmic | O(log n) | 1 | Def | Def Linear | O(n) | 2n | Find largest & smallest numbers | Finding index of an element in an array Quadratic | O(n^2) | n^2 | Constant time operation inside two nested for-loops. Exponential | O(c^n) | n^2 | Def | Guessing an n-character long password
- Array-lookup - Complete