Definition:
Big-O notation describes the upper bound of an algorithm’s time or space complexity as input size grows. It expresses the worst-case scenario performance, helping developers compare algorithm efficiency.
Example:
- Common Big-O Examples
Notation Name Description Example Algorithm O(1) Constant Same time regardless of input size Array access by index O(log n) Logarithmic Time increases slowly Binary search O(n) Linear Time grows proportionally Linear search O(n log n) Log-linear Efficient sorting algorithms Merge sort, Quick sort O(n²) Quadratic Time grows exponentially Bubble sort, nested loops O(2ⁿ) Exponential Extremely slow growth Recursive Fibonacci