Consider the following recursive implementation to find the largest element in a linked list:
struct Node
{
int val;
struct Node* next;
}*head;
int max_of_two(int a, int b)
{
if(a > b)
return a;
return b;
}
int recursive_get_max(struct Node* temp)
{
if(temp->next == 0)
return temp->val;
return max_of_two(______, _______);
}
Which of the following arguments should be passed to the function max_of two() to complete the above code?
struct Node
{
int val;
struct Node* next;
}*head;
int max_of_two(int a, int b)
{
if(a > b)
return a;
return b;
}
int recursive_get_max(struct Node* temp)
{
if(temp->next == 0)
return temp->val;
return max_of_two(______, _______);
}
A. temp->val,recursive_get_max(temp->next)
B. temp, temp->next
C. temp->val, temp->next->val
D. temp->next->val, temp
Answer: Option A
Join The Discussion