Algorithm Analysis and Complexity Flashcards
What is time complexity
a measure of how an algorithms runtime grows with input size.
What is Big-O notation?
A mathematical notation describing an algorithm’s worst-case growth rate.
What are common time complexities from best to worst?
O(1) < O(log n) < O(n) < O(n log n) < O(n²) < O(2ⁿ) < O(n!).
What does Big-O notation describe?
The upper bound of an algorithm’s growth rate (worst-case performance).
What is Omega (Ω) notation?
The lower bound of an algorithm’s growth rate (best-case performance).
What is Theta (Θ) notation?
The tight bound—both the upper and lower bounds of an algorithm’s growth rate.
What is amortized complexity?
The average time per operation over a sequence of operations (e.g., resizing an array-based dynamic list).
Give an example of an algorithm with O(1) time complexity.
Hash table lookup (assuming no collisions).
What is an invariant in algorithms?
A property that remains true at each step of execution (used in loop invariants).
How do you prove an algorithm is correct?
Using induction or loop invariants.