Free Practice Quiz Question List

05 Recursion Online Quiz Questions

Use this free practice quiz with 20 questions to review 05 Recursion, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

Which role does the base case play in a correct recursive algorithm?

  1. A

    It divides the input into equal-sized parts.

  2. B

    It provides a directly known answer and stops further calls.

  3. C

    It stores every previously computed result.

  4. D

    It reverses the most recent choice.

02
True or false
1 point

True or false: Recursive calls return in last-in, first-out order because they are managed by the call stack.

  1. A

    True

  2. B

    False

03
Written response
1 point

What is the name of the part of a recursive algorithm that reduces the problem to one or more smaller instances of the same problem?

04
Fill in the blank
1 point

Complete the two role descriptions: The reduces the problem and makes another recursive call, while the provides a direct answer and prevents further calls.

05
Choose one
1 point

The function sumTo(n)sumTo(n) makes one recursive call on n−1n-1 and performs constant additional work. What is its running time?

  1. A

    O(n)

  2. B

    O(log n)

  3. C

    O(n log n)

  4. D

    O(2^n)

06
Choose all
1 point

Select all statements that correctly describe the recursive binary-search implementation in the material.

  1. A

    Its running time is O(log n).

  2. B

    It always examines every element in the array.

  3. C

    Its recursive call-stack space is O(log n).

  4. D

    It has exponential running time because each call makes two recursive calls.

07
True or false
1 point

True or false: In backtracking, the algorithm must undo a choice after the recursive exploration of that choice finishes.

  1. A

    True

  2. B

    False

08
Fill in the blank
1 point

The recurrence T(n)=2T(n/2)+O(n)T(n)=2T(n/2)+O(n) is associated with merge sort. Its running time is .

09
Choose all
1 point

Select all consequences of applying the memoized Fibonacci implementation from the material to compute fib(n)fib(n).

  1. A

    The time complexity becomes O(n).

  2. B

    The time complexity remains O(2^n).

  3. C

    The memoization table requires O(n) additional storage.

  4. D

    Memoization guarantees O(1) total space.

10
Open ended
1 point

Explain how to design and evaluate a correct recursive algorithm. Your answer must discuss the base case, recursive case, progress toward termination, call-stack behavior, and the main complexity considerations.

11
Choose one
1 point

Which algorithm in the material is described as having commonly expressed running time O(2^n) because it repeatedly solves overlapping subproblems?

  1. A

    Memoized Fibonacci

  2. B

    Direct recursive Fibonacci without memoization

  3. C

    Iterative factorial

  4. D

    Recursive binary search

12
Written response
1 point

What is the auxiliary-space complexity of the iterative factorial implementation in the material? Enter the bound in Big-O notation.

13
Choose one
1 point

Which part of a recursive algorithm directly handles a simplest input and prevents further recursive calls?

  1. A

    The recursive case

  2. B

    The base case

  3. C

    The call-stack frame

  4. D

    The memoization case

14
Choose one
1 point

When recursive function calls return after reaching a base case, which order does the call stack follow?

  1. A

    First-in, first-out

  2. B

    Random order based on input size

  3. C

    Last-in, first-out

  4. D

    All frames return simultaneously

15
Choose one
1 point

A recursive binary search examines the middle of a sorted array and discards half of the remaining range on each call. What is its running time?

  1. A

    O(log⁡n)O(\log n)

  2. B

    O(n)O(n)

  3. C

    O(nlog⁡n)O(n\log n)

  4. D

    O(2n)O(2^n)

16
Choose one
1 point

A recursive traversal processes each node of a tree once. Which complexity description is correct, where nn is the number of nodes and hh is the tree height?

  1. A

    O(1)O(1)

  2. B

    O(n)O(n) for both time and stack space

  3. C

    O(log⁡n)O(\log n) for both time and stack space

  4. D

    O(n)O(n) time and O(h)O(h) stack space

17
Choose one
1 point

A direct recursive Fibonacci algorithm is changed to use memoization. What is the resulting time and additional-storage complexity?

  1. A

    It changes the algorithm to constant time and uses no extra memory.

  2. B

    It reduces the time to O(n)O(n) and uses O(n)O(n) additional storage.

  3. C

    It reduces the time to O(log⁡n)O(\log n) and uses O(1)O(1) additional storage.

  4. D

    It increases the time to O(n2)O(n^2) but removes the recursion stack.

18
True or false
1 point

True or false: The straightforward recursive and iterative implementations of factorial can both take O(n)O(n) time, but the iterative version can use O(1)O(1) auxiliary space while the recursive version uses O(n)O(n) call-stack space.

  1. A

    True

  2. B

    False

19
Written response
1 point

The recursive function is defined by S(n)=n+S(n−1)S(n)=n+S(n-1) with S(0)=0S(0)=0. What value does S(4)S(4) return?

20
Written response
1 point

What algorithmic technique stores the results of previously computed recursive subproblems so repeated subproblems can be answered without recomputation?