Week 3 Flashcards
measures the worst-case complexity of an algorithm. n represents the number of inputs.
The Big-O notation
does not change with respect to input space. Hence, it is referred to as being —. An example of an it algorithm is accessing an item in the array by its index.
O(1) - Constant Time
applies to algorithms that must do n operations in the worst-case scenario.
O(n) - Linear Time
The runtime grows logarithmically as the input size increases. Typically seen in algorithms that divide the problem in half each time.
O(log n) - Logarithmic Time
The runtime grows proportionally to the square of the input size. Often seen in algorithms with nested loops.
O(n^2) - Quadratic Time
The runtime grows proportionally to the cube of the input size. Less common but seen in some complex algorithms with multiple nested loops.
O(n^3) - Cubic Time
The runtime grows faster than exponential time. This is extremely inefficient and rare.
O(n^n) - Exponential Time (Super-Exponential)