Complete the code to start traversing the linked list from the head node.
struct Node* current = [1];The traversal of a linked list starts from the head node, so we assign the head pointer to the current pointer.
Complete the condition to continue traversing until the end of the linked list.
while (current [1] NULL) { // process current node current = current->next; }
The loop should continue as long as current is not NULL, meaning there are nodes left to visit.
Fix the error in the condition to check if the current node's data matches the target value.
if (current->data [1] target) { return 1; // found }
Use '==' to compare values for equality in C. '=' is assignment, which is incorrect here.
Fill both blanks to complete the search function that returns 1 if found, 0 otherwise.
struct Node* current = head; while (current [1] NULL) { if (current->data [2] target) { return 1; } current = current->next; } return 0;
The loop continues while current is not NULL, and inside the loop, we check if current->data equals the target.
Fill all three blanks to create a function that searches for a value in a linked list and returns 1 if found, else 0.
int search(struct Node* head, int target) {
struct Node* current = [1];
while (current [2] NULL) {
if (current->data [3] target) {
return 1;
}
current = current->next;
}
return 0;
}The function starts from head, loops while current is not NULL, and checks if current->data equals the target.
