Big-O Notation — Data Structures 練習ワークシート
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.
練習するスキル
- Classifying algorithms by Big-O
- Comparing growth rates
- Analyzing loops and nested loops
- Connecting structure choice to complexity
練習ワークシート:Big-O Notation
指示: 各問題を丁寧に解きましょう。途中式もはっきりと書きましょう。最終的な答えは、指定された場所または指示に従って別の用紙に書いてください。
-
1.Determine the Big-O complexity of the following function: . Provide a brief justification.
Big-O Notation — 練習ワークシート(続き)
-
2.Sort the following functions in increasing order of asymptotic growth rate (from slowest to fastest): , , , , , , . Write your final ordering.
Big-O Notation — 練習ワークシート(続き)
-
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.
Big-O Notation — 練習ワークシート(続き)
-
4.True or False: . Justify your answer.
Big-O Notation — 練習ワークシート(続き)
-
5.Multiple Choice: Which of the following is equivalent to ?
- A. and
- B. only
- C. only
- D. Neither nor
Big-O Notation — 練習ワークシート(続き)
-
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.
Big-O Notation — 練習ワークシート(続き)
-
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.
Big-O Notation — 練習ワークシート(続き)
-
9.Prove or disprove: . Provide a formal proof using the definition of Big-Omega.
Big-O Notation — 練習ワークシート(続き)
-
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.
解答集
-
1.
The highest-order term is , so the function grows as . All lower-order terms are dominated.最終回答:
-
2.
最終回答: , , , , , ,
-
3.
The outer loop runs times, and the inner loop runs an average of times, giving approximately operations, which is .最終回答:
-
4.
, so for and all . Thus .最終回答: True
-
5.
By definition, means the function is both and .最終回答: (A) and
解答集(続き)
-
6.
Using the Master Theorem with , , , we have , and , so case 2 applies: .最終回答:
-
7.
Compare: vs . Since grows slower than , is asymptotically smaller, so but not .最終回答:
-
8.
The sum , which is .最終回答: (C)
-
9.
We need constants and such that for all . Choose and : for all . Thus .最終回答: True
-
10.
The algorithm must examine each element once to find the maximum, requiring comparisons in the worst case, which is .最終回答:
避けるべきよくある間違い
- 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ⁿ)
自分だけのワークシートを作成
好きな難易度でbig-o notationの問題を新しく作成したいですか?WorksheetSmithを使えば、印刷可能なカスタムPDFを数秒で作成できます。
最終更新:2026