Skills101
← All practice quizzes

Recursion & Backtracking Quiz

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

Base cases, the call stack, recursion trees and the choose–explore–unchoose template.

Log in to take the quiz

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

  1. Question 1

    What happens if a recursive function has no base case?

  2. Question 2

    What does this print?

    def f(n):
        if n <= 1:
            return 1
        return n * f(n - 1)
    print(f(5))
    
  3. Question 3

    How many subsets does a set of 4 distinct elements have?

  4. Question 4

    How many permutations does [1, 2, 3] have?

  5. Question 5

    What are the three steps of the backtracking template?

  6. Question 6

    Why must you append a COPY of path (path[:] / new ArrayList<>(path)) to the results?

  7. Question 7

    Naive recursive Fibonacci fib(n) = fib(n−1) + fib(n−2) has roughly what time complexity?

  8. Question 8Select all that apply

    To avoid duplicate combinations when the input has repeated numbers (Subsets II), you… (select all that apply)