Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a recursive function named isPalindrome that accepts a string parameter and returns true if the string is the same forwards as backwards, ignoring capitalization.
Write a recursive function named isPalindrome that accepts a string parameter and returns true if the string is the same forwards as backwards, ignoring capitalization. For example, the call of isPalindrome("Madam") should return true.
I only get 9/13 correct and am unsure as to why.
write a recursive function named isPalindrome that accepts a string parameter and returns true if the string is the same forwards as backwards, ignoring capitalization. For example, the call of isPalindrome ("Madam") should return true. Constraints: Do not declare any global variables or any auxiliary data structures. Do not use any loops; you must use recursion. Type your solution here: 1 bool is Palindrome (string str) 3 if (str. length() str length 1) return true return isPalindrome (str.substr C1, str length 1)) 8 else if (str.at (0) str.at (1)) return true; 10 else if (str.at (0) E str.at (str. length() 1)) return true 12 return isPalindrome (str.substr C1, str length 1)) 13 14 15 16 17 else return false; 18 19Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started