Big-O Notation — Fiche d'exercices de 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.
Compétences travaillées
- Classifying algorithms by Big-O
- Comparing growth rates
- Analyzing loops and nested loops
- Connecting structure choice to complexity
Fiche d'exercices : Big-O Notation
Consignes : Résous chaque problème avec soin. Montre clairement tout ton travail. Écris ta réponse finale dans l'espace prévu ou sur une feuille séparée comme indiqué.
-
1.Determine the Big-O complexity of the following function: . Provide a brief justification.
Big-O Notation — Fiche d'exercices (suite)
-
2.Sort the following functions in increasing order of asymptotic growth rate (from slowest to fastest): , , , , , , . Write your final ordering.
Big-O Notation — Fiche d'exercices (suite)
-
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 — Fiche d'exercices (suite)
-
4.True or False: . Justify your answer.
Big-O Notation — Fiche d'exercices (suite)
-
5.Multiple Choice: Which of the following is equivalent to ?
- A. and
- B. only
- C. only
- D. Neither nor
Big-O Notation — Fiche d'exercices (suite)
-
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 — Fiche d'exercices (suite)
-
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 — Fiche d'exercices (suite)
-
9.Prove or disprove: . Provide a formal proof using the definition of Big-Omega.
Big-O Notation — Fiche d'exercices (suite)
-
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.
Corrigé
-
1.
The highest-order term is , so the function grows as . All lower-order terms are dominated.Réponse finale :
-
2.
Réponse finale : , , , , , ,
-
3.
The outer loop runs times, and the inner loop runs an average of times, giving approximately operations, which is .Réponse finale :
-
4.
, so for and all . Thus .Réponse finale : True
-
5.
By definition, means the function is both and .Réponse finale : (A) and
Corrigé (suite)
-
6.
Using the Master Theorem with , , , we have , and , so case 2 applies: .Réponse finale :
-
7.
Compare: vs . Since grows slower than , is asymptotically smaller, so but not .Réponse finale :
-
8.
The sum , which is .Réponse finale : (C)
-
9.
We need constants and such that for all . Choose and : for all . Thus .Réponse finale : True
-
10.
The algorithm must examine each element once to find the maximum, requiring comparisons in the worst case, which is .Réponse finale :
Erreurs fréquentes à éviter
- 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ⁿ)
Générez la vôtre
Vous voulez un nouvel ensemble de problèmes de big-o notation à la difficulté de votre choix ? Utilisez WorksheetSmith pour compiler un PDF personnalisé prêt à imprimer en quelques secondes.
Dernière mise à jour : 2026