Free Online Flashcard Deck

05 Recursion Free Online FlashCards

Study 05 Recursion with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is recursion?

Back

Recursion is a technique in which a function calls itself on a smaller or simpler version of the original problem.

02
Front

What is the purpose of a base case?

Back

The base case gives an answer directly and prevents further recursive calls.

03
Front

What does a recursive case do?

Back

The recursive case reduces the problem, calls the function on the smaller instance, and combines the returned result when necessary.

04
Front

What does a recursive call add to the call stack?

Back

Each active recursive call creates a stack frame containing parameters, local state, and a return location.

05
Front

In what order do recursive calls return?

Back

Recursive calls return in last-in, first-out order: the most recent call returns before its caller resumes.

06
Front

What is factorial recursion's call-stack space?

Back

For the recursive factorial implementation, the maximum call-stack depth is n+1n+1, so its call-stack space is O(n)O(n).

07
Front

What is decrease-and-conquer?

Back

Decrease-and-conquer makes one recursive call on a smaller problem, often of size n−1n-1 or n/2n/2.

08
Front

What are binary search's recursive time and stack bounds?

Back

Binary search has recurrence T(n)=T(n/2)+O(1)T(n)=T(n/2)+O(1), giving O(log⁡n)O(\log n) time and O(log⁡n)O(\log n) recursive stack space.

09
Front

What is the complexity of recursive tree traversal?

Back

A recursive tree traversal processes each node once, taking O(n)O(n) time and O(h)O(h) stack space, where hh is tree height.

10
Front

What is the core cycle of backtracking?

Back

Backtracking applies a choice, recursively explores the resulting state, then undoes the choice before trying another option.

11
Front

Why is naive recursive Fibonacci exponential?

Back

Naive recursive Fibonacci takes commonly expressed exponential time, O(2n)O(2^n), because it repeatedly recomputes overlapping subproblems.

12
Front

How does memoization improve recursive Fibonacci?

Back

Memoization stores computed subproblem results. For Fibonacci, it reduces time to O(n)O(n) and uses O(n)O(n) additional storage.