Big-O Notation — Data Structures Übungsblatt
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.
Geübte Fähigkeiten
- Classifying algorithms by Big-O
- Comparing growth rates
- Analyzing loops and nested loops
- Connecting structure choice to complexity
Übungsblatt: Big-O Notation
Anleitung: Löse jede Aufgabe sorgfältig. Zeige deine Arbeit klar. Schreibe deine endgültige Antwort in das vorgesehene Feld oder wie angewiesen auf ein separates Blatt.
-
1.Determine the Big-O complexity of the following function: . Provide a brief justification.
Big-O Notation — Übungsblatt (Fortsetzung)
-
2.Sort the following functions in increasing order of asymptotic growth rate (from slowest to fastest): , , , , , , . Write your final ordering.
Big-O Notation — Übungsblatt (Fortsetzung)
-
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 — Übungsblatt (Fortsetzung)
-
4.True or False: . Justify your answer.
Big-O Notation — Übungsblatt (Fortsetzung)
-
5.Multiple Choice: Which of the following is equivalent to ?
- A. and
- B. only
- C. only
- D. Neither nor
Big-O Notation — Übungsblatt (Fortsetzung)
-
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 — Übungsblatt (Fortsetzung)
-
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 — Übungsblatt (Fortsetzung)
-
9.Prove or disprove: . Provide a formal proof using the definition of Big-Omega.
Big-O Notation — Übungsblatt (Fortsetzung)
-
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.
Lösungsschlüssel
-
1.
The highest-order term is , so the function grows as . All lower-order terms are dominated.Endgültige Antwort:
-
2.
Endgültige Antwort: , , , , , ,
-
3.
The outer loop runs times, and the inner loop runs an average of times, giving approximately operations, which is .Endgültige Antwort:
-
4.
, so for and all . Thus .Endgültige Antwort: True
-
5.
By definition, means the function is both and .Endgültige Antwort: (A) and
Lösungsschlüssel (Fortsetzung)
-
6.
Using the Master Theorem with , , , we have , and , so case 2 applies: .Endgültige Antwort:
-
7.
Compare: vs . Since grows slower than , is asymptotically smaller, so but not .Endgültige Antwort:
-
8.
The sum , which is .Endgültige Antwort: (C)
-
9.
We need constants and such that for all . Choose and : for all . Thus .Endgültige Antwort: True
-
10.
The algorithm must examine each element once to find the maximum, requiring comparisons in the worst case, which is .Endgültige Antwort:
Häufige Fehler, die es zu vermeiden gilt
- 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ⁿ)
Erstelle dein eigenes Arbeitsblatt
Möchtest du neue big-o notation-Aufgaben in deiner gewünschten Schwierigkeit? Nutze WorksheetSmith, um in Sekunden ein individuelles, druckfertiges PDF zu erstellen.
Zuletzt aktualisiert: 2026