Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I want to check for palindrome within an array. But this function isn't working. Please correct THIS function. Provide detailed explanation. #include #include using namespace
I want to check for palindrome within an array. But this function isn't working. Please correct THIS function. Provide detailed explanation.
#include#include using namespace std; bool checkPal(int arr[], int size) { if (size == 0) return true; if (arr[0] == arr[size-1]) { return checkPal(arr + 1, size - 1); } else { return false; } } int main() { int arr[6] = { 1,3,2,2,3,1 }; cout << checkPal(arr, 6); //Output true if it is palindrome }
Step 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