Big-O Notation — Data Structures Practice Worksheet
Big-O notation describes how an algorithm's runtime or space grows as input size n increases. It focuses on worst-case asymptotic behavior and ignores constants and lower-order terms.
Common classes from fastest to slowest: O(1) constant, O(log n) logarithmic, O(n) linear, O(n log n) linearithmic, O(n²) quadratic, O(2ⁿ) exponential.
Examples: array index access O(1); binary search O(log n); linear scan O(n); nested loops over n O(n²); recursive Fibonacci without memo O(2ⁿ). Choose data structures to match operation needs.
Skills practiced
- Classifying algorithms by Big-O
- Comparing growth rates
- Analyzing loops and nested loops
- Connecting structure choice to complexity
Practice Worksheet: Big-O Notation
Instructions: Solve each problem carefully. Show all work clearly. Write your final answer in the space provided or on a separate sheet as directed.
-
1.Determine the Big-O complexity of the following function: . Provide a brief justification.
-
2.Sort the following functions in increasing order of asymptotic growth rate (from slowest to fastest): , , , , , , . Write your final ordering.
-
3.Consider the following code fragment:
for i = 1 to n: for j = 1 to i: print(i + j)What is the Big-O time complexity of this code? Explain your reasoning. -
4.True or False: . Justify your answer.
-
5.Multiple Choice: Which of the following is equivalent to ?
- A. and
- B. only
- C. only
- D. Neither nor
-
6.Determine the Big-O complexity of the recurrence . Assume . Show your work using the Master Theorem or iteration method.
-
7.Given and , determine whether , , or . Justify your answer.
-
8.Multiple Choice: What is the Big-O complexity of the following function? \[ f(n) = \sum_{i=1}^{n} i^2 \]
- A.
- B.
- C.
- D.
-
9.Prove or disprove: . Provide a formal proof using the definition of Big-Omega.
-
10.Consider the algorithm that finds the maximum element in an unsorted array of size . What is the tightest asymptotic bound for its worst-case time complexity? Explain why.
Answer Key
-
1.
The highest-order term is , so the function grows as . All lower-order terms are dominated.Final answer:
-
2.
Final answer: , , , , , ,
-
3.
The outer loop runs times, and the inner loop runs an average of times, giving approximately operations, which is .Final answer:
-
4.
, so for and all . Thus .Final answer: True
-
5.
By definition, means the function is both and .Final answer: (A) and
-
6.
Using the Master Theorem with , , , we have , and , so case 2 applies: .Final answer:
-
7.
Compare: vs . Since grows slower than , is asymptotically smaller, so but not .Final answer:
-
8.
The sum , which is .Final answer: (C)
-
9.
We need constants and such that for all . Choose and : for all . Thus .Final answer: True
-
10.
The algorithm must examine each element once to find the maximum, requiring comparisons in the worst case, which is .Final answer:
Common mistakes to avoid
- Confusing best case with Big-O (usually worst case)
- Calling O(2n) different from O(n) — constants drop
- Ignoring hidden loops in string operations
- Assuming recursion is always O(2ⁿ)
Generate your own like this
Want a fresh set of big-o notation problems at your chosen difficulty? Use WorksheetSmith to compile a custom, print-ready PDF in seconds.
Last updated: 2026