Respuesta :

A recursive approach to finding the maximum element in the array is given below:

Approach:  

  • Get the array for which the maximum is to be found
  • Recursively find the maximum according to the following:
  • Recursively traverse the array from the end

Base case: If the remaining array is of length 1, return the only present element i.e.

arr[0]

if(n == 1)

  return arr[0];

The Program Implementation

// Recursive C++ program to find maximum

#include <iostream>

using namespace std;

// function to return maximum element using recursion

int findMaxRec(int A[], int n)

{

  // if n = 0 means whole array has been traversed

   if (n == 1)

       return A[0];

   return max(A[n-1], findMaxRec(A, n-1));

}

// driver code to test above function

int main()

{

   int A[] = {1, 4, 45, 6, -50, 10, 2};

   int n = sizeof(A)/sizeof(A[0]);

   cout <<  findMaxRec(A, n);

   return 0;

}

Read more about recursive algorithms here:

https://brainly.com/question/489759

#SPJ1