Free Online Flashcard Deck

2 Recursion Free Online FlashCards

Study 2 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 solves a problem by having a function call itself on a smaller or simpler version of that problem.

02
Front

What is a base case?

Back

A base case is a condition whose answer is known directly and that stops further recursive calls.

03
Front

What is a recursive case?

Back

A recursive case reduces the problem and calls the same function on a smaller instance.

04
Front

What does progress mean in recursion?

Back

Each recursive call must move closer to a base case, usually by reducing the input or advancing through a structure.

05
Front

How does recursion use the call stack?

Back

The call stack stores active function calls in last-in, first-out order, so the most recent recursive call returns first.

06
Front

What is recursion depth?

Back

Recursion depth is the maximum number of simultaneously active recursive calls. It determines the stack space used by the recursion.

07
Front

What is the cost of decrease-by-one recursion?

Back

A decrease-by-one recurrence has the form T(n)=T(n−1)+O(1)T(n) = T(n-1) + O(1), giving O(n)O(n) running time and typically O(n)O(n) call depth.

08
Front

Why is recursive binary search O(log⁡n)O(\log n)?

Back

Binary search follows T(n)=T(n/2)+O(1)T(n) = T(n/2) + O(1), so its running time and recursion depth are both O(log⁡n)O(\log n).

09
Front

Why is naive recursive Fibonacci inefficient?

Back

Naive recursive Fibonacci recomputes the same subproblems many times, producing exponential running time. Memoization reduces the running time to O(n)O(n).

10
Front

What recurrence describes merge sort?

Back

Merge sort divides the array, recursively sorts both halves, and merges them. Its recurrence is T(n)=2T(n/2)+O(n)T(n) = 2T(n/2) + O(n), giving O(nlog⁡n)O(n \log n) time.

11
Front

Why is binary-tree traversal O(n)O(n)?

Back

A tree traversal uses the empty tree as its base case and recursively processes child subtrees. Visiting each node once gives O(n)O(n) running time.

12
Front

What is backtracking?

Back

Backtracking recursively explores a choice, then undoes it before trying another choice. Pruning invalid partial solutions can reduce the search.