1. Home
  2. Explore
  3. Computer Science
  4. Big O Notation Examples

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Big O Notation Examples

  • 41Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Big O Fundamentals
Big O notation is a tool used to analyze algorithms and data structures based on the approximate number of
in the worst case.

41 questions

  1. 1
    Big O notation is a tool used to analyze algorithms and data structures based on the approximate number of
    _____
    in the worst case.
    Hint

    Think about what we count to estimate how long an algorithm takes.

    Answer

    operations

  2. 2
    Big O notation focuses on what happens when the input size is
    _____
    .
    Hint

    It's about scaling to large inputs, not small ones.

    Answer

    very large

  3. 3
    In time complexity analysis, we consider the
    _____
    case scenario to determine Big O notation.
    Hint

    We want to guarantee an upper bound on runtime.

    Answer

    worst

  4. 4
    The variable
    _____
    is commonly used to represent the size of the input.
    Hint

    It's a standard placeholder for input size.

    Answer

    n

  5. 5
    The first step in determining Big O notation is to find the approximate number of
    _____
    for the algorithm.
    Hint

    What do we count before simplifying?

    Answer

    operations

  6. 6
    In the mathematical definition, f(n)=O(g(n))f(n) = O(g(n))f(n)=O(g(n)) means there exist constants ccc and NNN such that for all n≥Nn \geq Nn≥N, $f(n) \leq c \cdot
    _____
    $.
    Hint

    It's the function that bounds f(n) from above.

    Answer

    g(n)g(n)g(n)

  7. 7
    In the Big O definition, the constants ccc and NNN must be at least
    _____
    .
    Hint

    They must be positive, and typically start from 1 or greater.

    Answer

    1

  8. 8
    When simplifying Big O, constants (coefficients) can be
    _____
    because they become less important as nnn grows.
    Hint

    They don't affect the growth rate.

    Answer

    dropped

  9. 9
    When terms are added together, we keep only the
    _____
    term in Big O notation.
    Hint

    Which term grows fastest as n increases?

    Answer

    largest

  10. 10
    When terms are multiplied together, we
    _____
    simply remove the smaller term because both affect the growth rate.
    Hint

    Multiplication is different from addition.

    Answer

    cannot

  11. 11
    A time complexity of O(1) means that the number of operations is
    _____
    regardless of input size.
    Hint

    It doesn't depend on n.

    Answer

    constant

  12. 12
    O(
    _____
    ) means that the number of operations grows logarithmically with the input size.
    Hint

    This complexity is better than linear.

    Answer

    log⁡n\log nlogn

  13. 13
    An algorithm with O(n) time complexity has a
    _____
    relationship between input size and operations.
    Hint

    It's a straight-line increase.

    Answer

    linear

  14. 14
    The time complexity O(nlog⁡nn \log nnlogn) is typical for efficient
    _____
    algorithms.
    Hint

    Think of common sorting methods like mergesort or heapsort.

    Answer

    sorting

  15. 15
    O(n2n^2n2) time complexity is often caused by
    _____
    loops.
    Hint

    When one loop runs inside another, each iterating over the input.

    Answer

    nested

  16. 16
    The time complexity O(
    _____
    ) indicates exponential growth, such as in the naive Fibonacci recursion.
    Hint

    Each call branches into two more calls.

    Answer

    2n2^n2n

  17. 17
    The worst time complexity among common functions is O(
    _____
    ), which is even worse than exponential.
    Hint

    It's the factorial function.

    Answer

    n!n!n!

  18. 18
    For a single loop that iterates nnn times with constant-time operations inside, the time complexity is O(
    _____
    ).
    Hint

    The loop runs n times.

    Answer

    nnn

  19. 19
    If an algorithm has two separate loops that each iterate over the input of size nnn, the total time complexity is O(
    _____
    ).
    Hint

    The loops are not nested.

    Answer

    nnn

  20. 20
    For a nested loop where both the outer and inner loops iterate over nnn elements, the time complexity is O(
    _____
    ).
    Hint

    The inner loop runs n times for each of the n outer iterations.

    Answer

    n2n^2n2

  21. 21
    When an algorithm has two different inputs with sizes nnn and mmm, we use notation O(
    _____
    ) to represent the combined time if the loops are separate.
    Hint

    We add the contributions from each input.

    Answer

    n+mn + mn+m

  22. 22
    For a nested list with height hhh and width www, double nested loops over both dimensions give time complexity O(
    _____
    ).
    Hint

    Multiply the two dimensions.

    Answer

    h⋅wh \cdot wh⋅w

  23. 23
    When processing a list of strings, if the longest string has length kkk, the time to iterate over characters in that string is O(
    _____
    ).
    Hint

    The loop runs for each character.

    Answer

    kkk

  24. 24
    A recursive function that makes two recursive calls and reduces the input by a constant amount (e.g., n−1n-1n−1 and n−2n-2n−2) has time complexity O(
    _____
    ).
    Hint

    Think about the Fibonacci sequence.

    Answer

    2n2^n2n

  25. 25
    A recursive function that makes one recursive call that reduces the input by dividing by 2 (e.g., n/2n/2n/2) has time complexity O(
    _____
    ).
    Hint

    The input size reduces by a factor each time.

    Answer

    log⁡n\log nlogn

  26. 26
    A recursive function that makes nnn recursive calls at each level, where the input decreases by 1, yields time complexity O(
    _____
    ).
    Hint

    Think about generating all permutations.

    Answer

    n!n!n!

  27. 27
    The built-in function max() on a list of size nnn has time complexity O(
    _____
    ).
    Hint

    It needs to examine every element.

    Answer

    nnn

  28. 28
    Sorting a list of size nnn using an efficient algorithm (like Python's built-in sort) has time complexity O(
    _____
    ).
    Hint

    The best comparison-based sorting is O(n log n).

    Answer

    nlog⁡nn \log nnlogn

  29. 29
    The operation pop(0) on a Python list of size nnn has time complexity O(
    _____
    ) because it shifts all remaining elements.
    Hint

    Removing the first element requires moving all others.

    Answer

    nnn

  30. 30
    In example 0, checking if a number is even or odd using modulus is an example of
    _____
    time complexity.
    Hint

    It takes the same time regardless of the number.

    Answer

    constant

  31. 31
    In example 1, a loop that sums all numbers in a list has time complexity O(
    _____
    ).
    Hint

    The loop runs as many times as there are numbers.

    Answer

    nnn

  32. 32
    In example 2, nested loops that compare all pairs in a list have time complexity O(
    _____
    ).
    Hint

    Both loops iterate over the same list.

    Answer

    n2n^2n2

  33. 33
    In example 3, two separate loops over two different lists of sizes nnn and mmm give time complexity O(
    _____
    ).
    Hint

    The loops are not nested.

    Answer

    n+mn + mn+m

  34. 34
    In example 4, processing a nested list with dimensions hhh and www has time complexity O(
    _____
    ).
    Hint

    It depends on both the number of inner lists and their length.

    Answer

    h⋅wh \cdot wh⋅w

  35. 35
    In example 5 (Fibonacci), the recursive function has time complexity O(
    _____
    ).
    Hint

    Each call spawns two more.

    Answer

    2n2^n2n

  36. 36
    In example 6, calling max() on a list of size nnn and then searching through a list of size mmm results in time complexity O(
    _____
    ).
    Hint

    Both operations are sequential and each is linear in its input.

    Answer

    n+mn + mn+m

  37. 37
    In example 7, a recursive function that divides nnn by 2 each call has time complexity O(
    _____
    ).
    Hint

    The input size halves each step.

    Answer

    log⁡n\log nlogn

  38. 38
    In example 8, processing a list of nnn strings where each string can be up to length kkk and sorting each string gives time complexity O(
    _____
    ).
    Hint

    Remember to account for both the outer loop and the sorting inside.

    Answer

    n⋅klog⁡kn \cdot k \log kn⋅klogk

  39. 39
    In example 9, with dictionaries of sizes nnn and mmm, and strings of max length kkk, the time complexity includes O(nlog⁡n+mlog⁡mn \log n + m \log mnlogn+mlogm plus O(
    _____
    ) for the while loop processing).
    Hint

    The while loop repeats for each element and each character removal.

    Answer

    (n+m)⋅k(n+m) \cdot k(n+m)⋅k

  40. 40
    In example 11, the triple nested loops give a time complexity of O(
    _____
    ).
    Hint

    Count the loops: one outer, two inner.

    Answer

    n3n^3n3

  41. 41
    In example 12, the recursive function with nnn recursive calls per level and decreasing input by 1 has time complexity O(
    _____
    ).
    Hint

    Think about the number of calls at each level.

    Answer

    n!n!n!

1 of 41
Question 1 of 41

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent