Answer:
Following are the code to this question:
In option (i):
#include <iostream>//defining header file
using namespace std;
int findMax(int B[], int x)//defining recursive method findMax
{
if (x == 1)//defining condition when value of n==1
return B[0];//return array first element
return max(B[x-1], findMax(B, x-1)); // calling recursive method inside max method and return value
}
int main() //defining main method
{
int B[] = {12, 24, 55, 60, 50, 30, 29};//defining array B
int x= 7;//defining integer variable and assign a value
cout << "Maximum element value of the array is: "<<findMax(B, x)<<endl;//calling method findMax and print value
return 0;
}
Output:
Maximum element value of the array is: 60
In option (ii):
[tex]\Rightarrow \ T(n) = 1 + T(n-1)\\\Rightarrow 1 + 1 + T(n-2)\\ \Rightarrow 1 + 1 + 1 + ... n \ times \\\Rightarrow O(n) \\[/tex]
Explanation:
In the above-given program a recursive method "findMax" is defined, which accepts an array "B" and an integer variable "n" in its parameter, inside the method a conditional statement is used that, checks value of x equal to 1.