Ask Question
17 April, 03:12

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, boolean-valued method, isPalindrome, that accepts an integer-valued array, and a pair of integers representing the starting and ending indexes of the portion of the array to be tested for being a palindrome. The function returns whether that portion of the array is a palindrome.

+4
Answers (1)
  1. 17 April, 03:36
    0
    Following are the function of array palindrome

    bool ischeckPalindrome (int a1[], int n) / / function definition

    {

    if (n= = 0 || n = = 1) / / check the condition

    {

    return true; / / returns true

    }

    else

    if (a1[0]! = a[n-1]) / / check condition

    return false; / /return false

    else

    return ischeckPalindrome (++a1, n - 2); / / portion of the array

    }

    Explanation:

    Following are the description of function.

    We declared the bool type function bool ischeckPalindrome (int a1[], int n) it returns true or false or any integer value. In this function we pass the array "a1[]", and the size of array i. e "n". In this we check the condition according to the need the if (n= = 0 || n = = 1) check the condition of array size 0 or 1. If it executed it returns true. If this condition is not executed the control goes to the else block. In this else we have used inner if - else statement. The if (a1[0]! = a[n-1]) verify the condition if array index 0 is not equal a[n-1] then it returns false other it returns the portion of the array. Finally this function check the palindrome condition.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “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 ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers