Recursion and Recurrence Relations Flashcards
(8 cards)
calls itself
What is recursion?
A function calling itself to solve a smaller instance of the same problem.
What is a base case in recursion?
The condition that stops the recursion to prevent infinite loops.
eq defining funct
What is a recurrence relation?
An equation defining a function in terms of smaller inputs.
Solve the recurrence relation: T(n) = T(n/2) + O(1).
O(log n) using the recurrence tree method.
What is tail recursion?
A recursive function where the recursive call is the last operation, allowing for optimization into iteration.
What is the recurrence relation for Merge Sort?
T(n) = 2T(n/2) + O(n).
What is the Master Theorem?
A formula to solve recurrence relations in divide-and-conquer algorithms.