Cracking the Coding Interview
Multipart Algorithm: Multiply
"Do this for each time you do that"
Multipart Algorithm: Add
"Do this, then, when done, do that."
Steps of the Problem Solving Strat
1. Listen 2. Example (Diagram and Draw) 3. Brute Force 4. Optimize (BUD system) 5. Walk Through (Talk it, Understand it) 6. Implement 7. Test
Big O Notation
A metric used to describe the efficiency of algorithms. Expression of how runtime scales.
Constant-time statement
A statement that is "simple" (only involves basic operations).
Time-complexity (of an algorithm)
Asymptotic runtime of an algorithm (a line that approaches a curve but never touches)
Amortized time
Average time required over a sequence of operations
Omega (big omega) (academia)
Describes the lower bound on the time.
O (big O) (academia)
Describes the upper bound on the time
Balanced Binary Search Tree (big O Notation)
O (log N)
Space Complexity
The concept of how much space (memory) an algorithm requires.
O(log N)
Typically describes when the number of elements in the problem space are halved at each iteration
Theta (big theta) (academia)
When an algorithm is both O(N) and Omega(N)
Dropping Non-Dominant Terms
When describing an algorithm like: O (N^2 + N) we ignore and remove the non-dominant term and describe is as O (N^2) instead. A non-dominant term is one that has a slower rate of increase.
Dropping Constants
trsting