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?
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;
}
A. temp = next
B. temp->next = temp
C. temp = temp->next
D. return 0
Answer: Option C
Join The Discussion