Big-O Notation – Algorithm Runtime Complexity & Efficiency
This article is a concept explainer on Big-O notation, complete with exam questions and key points.
In a Nutshell
Big-O notation describes how the runtime or memory requirements of an algorithm scale relative to the input size—it’s a measure of algorithmic efficiency.
Core Technical Definition
Big-O notation is used to analyze the asymptotic complexity of an algorithm. It abstracts away concrete execution times and focuses on behavior as input grows. The worst-case scenario determines the number of computational steps or memory accesses required. Common examples: O(1) = constant, O(n) = linear, O(n²) = quadratic, O(log n) = logarithmic. This allows you to compare algorithms independent of hardware.
Key Exam Concepts
- Big-O describes growth behavior of runtime and memory
- Worst case is analyzed by default
- Typical notations: O(1), O(n), O(log n), O(n²), O(n log n)
- Logarithmic complexity appears in binary search
- Quadratic algorithms become inefficient with large datasets
- Efficient algorithms reduce resource consumption and have economic value
- Big-O analysis should be documented for complex algorithms
Main Components
- Constant: O(1)
- Linear: O(n)
- Logarithmic: O(log n)
- Linear-logarithmic: O(n log n)
- Quadratic: O(n²)
- Cubic: O(n³)
- Exponential: O(2ⁿ)
- Worst-case analysis
- Best-case, average-case analysis
- Relevance for scalability
Practical Example
// Comparison: linear vs. binary search
Linear search: O(n)
Binary search: O(log n), only on sorted lists
Explanation: Linear search iterates through the entire list, while binary search halves the search space at each step—much more efficient with large datasets.
Strengths and Limitations
Strengths
- Compare algorithms regardless of implementation details
- Identify potential bottlenecks early
- Make better architectural decisions during design
Limitations
- Says nothing about concrete runtime on specific hardware
- Focuses on worst case without considering averages
- Theoretical; doesn’t always map directly to real-world conditions
Common Exam Questions (with Brief Answers)
- What does Big-O notation describe? Algorithm complexity in terms of runtime or memory requirements as input grows.
- What does O(1) mean? Runtime is constant—independent of input size.
- Which is more efficient: O(n) or O(log n)? O(log n), because it scales much better as data volume increases.
- What does “n” represent in O(n)? The number of input elements.
- Which algorithm is typically O(n log n)? Merge Sort or Quick Sort on average.
- Why is O(n²) problematic? Runtime grows quadratically with large datasets.
- Can an algorithm be both O(n) and O(n²) simultaneously? No—always express the dominant component.
- How do you document Big-O analysis? Through code comments, diagrams, or formal analysis documentation.
Essential Resources
- https://www.bigocheatsheet.com/
- https://visualgo.net/en
- https://www.geeksforgeeks.org/analysis-of-algorithms-set-1-asymptotic-analysis/
- https://cs50.harvard.edu/
- https://www.youtube.com/results?search_query=big+o+notation



