Big-O Notation – Algorithm Complexity & Efficiency
This article is a conceptual guide to Big-O notation, including exam questions and key takeaways.
In a Nutshell
Big-O notation describes how runtime or memory requirements grow relative to input size—it’s a measure of algorithmic efficiency.
Technical Overview
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 increases. Specifically, it expresses the worst-case number of computational steps or memory accesses an algorithm requires. Common examples include O(1) for constant time, O(n) for linear, O(n²) for quadratic, and O(log n) for logarithmic. This allows you to compare algorithms independent of hardware.
Key Exam Points
- Big-O describes how runtime and memory scale with input growth
- Worst-case analysis is the standard approach
- Common 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—important for cost and sustainability
- Big-O analysis should be documented in complex code
Core Concepts
- Constant: O(1)
- Linear: O(n)
- Logarithmic: O(log n)
- Linearithmic: O(n log n)
- Quadratic: O(n²)
- Cubic: O(n³)
- Exponential: O(2ⁿ)
- Worst-case analysis
- Best-case and average-case scenarios
- Relevance to scalability
Practical Example
// Comparison: linear vs. binary search
Linear search: O(n)
Binary search: O(log n), only works on sorted lists
Why: Linear search traverses the entire list, while binary search halves the search space at each step—dramatically faster with large datasets.
Strengths and Limitations
Strengths
- Compare algorithms independent of implementation details
- Identify potential bottlenecks early
- Better design decisions in architectural phases
Limitations
- No insight into actual execution time on specific hardware
- Only considers worst-case; average cases may differ significantly
- Theoretical; doesn’t always transfer directly to real-world conditions
Common Exam Questions (With Quick Answers)
- What does Big-O notation describe? The complexity of an algorithm in terms of runtime or memory as input size grows.
- What does O(1) mean? Runtime is constant and independent of input size.
- More efficient: O(n) or O(log n)? O(log n), because it’s much faster 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—only the dominant component is reported.
- How should Big-O be documented? Through code comments, diagrams, or formal analysis.
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



