Examveda

Consider the following recursive implementation to find the largest element in an array.
int max_of_two(int a, int b)
{
      if(a > b)
        return a;
      return b;
}
int recursive_max_element(int *arr, int len, int idx)
{
      if(idx == len - 1)
      return arr[idx];
      return _______;
}
Which of the following lines should be inserted to complete the above code?

A. max_of_two(arr[idx], recursive_max_element(arr, len, idx))

B. recursive_max_element(arr, len, idx)

C. max_of_two(arr[idx], recursive_max_element(arr, len, idx + 1))

D. recursive_max_element(arr, len, idx + 1)

Answer: Option C


This Question Belongs to Data Structure >> Miscellaneous On Data Structures

Join The Discussion

Related Questions on Miscellaneous on Data Structures