Examveda

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

A. temp = next

B. temp->next = temp

C. temp = temp->next

D. return 0

Answer: Option C


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

Join The Discussion

Related Questions on Miscellaneous on Data Structures