Vidyalelo
Data Structure · Q876

Miscellaneous on Data Structures

Programming · Data Structure · question 876

Q876

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))
Answer
D.
recursive_max_element(arr, len, idx + 1)

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board