A 'array palindrome' is an array which, when its elements are reversed, remains the same (i.e., the elements of the array are same when scanned forward or backward) Write a recursive, bool-valued function, isPalindrome, that accepts an integer-valued array, and the number of elements and returns whether the array is a palindrome. An array is a palindrome if: the array is empty (0 elements) or contains only one element (which therefore is the same when reversed), or the first and last elements of the array are the same, and the rest of the array (i.e., the second through next-to-last elements) form a palindrome.

Respuesta :

The code below is used to determine a recursive, bool-valued function, isPalindrome, that accepts an integer-valued array, and the number of elements and returns whether the array is a palindrome.

Explanation:

  • The code shows 'array palindrome' is an array which, when its elements are reversed, remains the same.

bool isPalindrome(arr[((n-1) - n) +1], n)

{

   if (n == 0 || n == 1)

   {

       return true;

   }

   else if (arr[n-1] == isPalindrome(arr[], n-1)

   {

       return true;

   }  

   else {

       return false;

   }

}

ACCESS MORE