Question: (Recursion and Recurrence Relations) (a) (10 pts) Write a recursive function that takes a string of length n and returns 1 if the string is


(Recursion and Recurrence Relations) (a) (10 pts) Write a recursive function that takes a string of length n and returns 1 if the string is a palindrome, 0 if the string is not a palindrome. A palindrome is a string that is spelled the same forwards as it is backwards. E.g., abba and aba are both palindromes, but abb is not. The empty string, , is also a palindrome. For simplicity, you may assume the string passed to your function contains lowercase letters only, and no spaces. Do not call strlen() under any circumstances! The function signature is: int isPalindrome(char *str, int n); (b) (10 pts) Solve the following recurrence relation using iterative substitution: T(0) = C2 T(n) = C1 + n + T(n-1) for n > 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
