Ask Question
22 January, 09:43

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.

+1
Answers (1)
  1. 22 January, 10:54
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers