Big O Flashcards
What is Big O?
Big 0 time is the language and metric we use to describe the efficiency of algorithms.
What is Time Complexity?
The upper time that an algorithm can take to finish
What is Space Complexity?
The upper space that an algorithm can take to finish
When should I add the runtimes?
If your algorithm is in the form “do this, then, when you’re all done, do that” then you add the runtimes.
When should I multiply the runtimes?
If your algorithm is in the form “do this for each time you do that” then you multiply the runtimes.
What is Amortized Time?
When the array hits the capacity, the ArrayList will create a new one with double the capacity. It allows us to describe that, yes, this worst case happens every once in a while. But once it happens, it won’t happen again for so long that the cost is “amortized.”
Log N Runtimes
When you see a problem where the number of elements in the problem space gets halved each time, that will likely be a 0(log N) runtime.
Recursive Runtimes
When you have a recursive function that makes multiple calls, the runtime will often (but not always) take like O(branches ^ (N+1)), where branches are the number of times each recursive call branches. In this case, this gives us 0( 2”).