Skills101
← All practice quizzes

Time & Space Complexity Quiz

8 questions10 minPass: 60%+10 XP on first pass

Can you find the Big-O of real code? 8 questions on loops, logarithms, recursion and space.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What is the time complexity of this code?

    for i in range(n):
        for j in range(n):
            print(i, j)
    
  2. Question 2

    What is the time complexity of this code?

    for i in range(n):
        print(i)
    for j in range(n):
        print(j)
    
  3. Question 3

    What is the time complexity of this loop?

    i = n
    while i > 1:
        i = i // 2
    
  4. Question 4

    Simplify the complexity 3n² + 5n + 100.

  5. Question 5

    An array has n ≤ 100,000 elements. Which solution is likely too slow for a typical 1-second limit?

  6. Question 6Select all that apply

    Which operations are O(1) on average? (select all that apply)

  7. Question 7

    What is the extra space complexity of this recursive function?

    def count_down(n):
        if n == 0:
            return
        count_down(n - 1)
    
  8. Question 8

    You loop over array a (length n) and, inside it, over array b (length m). What is the time complexity?