Recursion & Backtracking Flashcards

1
Q

What is recursion? How does it differ from iteration?

A

Recursion has function calls (stack overhead), iteration does not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the base case in recursion?

A

The condition that stops recursion.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is tail recursion? Why is it useful?

A

Recursive call is the last operation in the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the time complexity of the recursive Fibonacci algorithm?

A

O(2ⁿ) (exponential).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are common problems that use backtracking?

A

N-Queens, Sudoku Solver, Subset Sum.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between backtracking and recursion?

A

Backtracking explores all possibilities but “backs up” on failures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly