Examveda

Consider the following code snippet to find the smallest element in a linked list:
struct Node
{
     int val;
     struct Node* next;
}*head;
int get_min()
{
      struct Node* temp = head->next;
	  int min_num = temp->val;
	  while(temp != 0)
	  {
	       if(_________)
		    min_num = temp->val;
		temp = temp->next;
	  }
	  return min_num;
}
Which of the following lines should be inserted to complete the above code?

A. temp > min_num

B. val > min_min

C. temp->val < min_num

D. temp->val > min_num

Answer: Option C


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

Join The Discussion

Related Questions on Miscellaneous on Data Structures