Following is the said code for the given function. function NodePtr list_search(NodePtr head, int target); The function will search through the linked list that is pointed by head and return a NodePtr that points to the Node that contains target as its item. If there is no such a Node, NULL will be returned.
NodePtr list_search(NodePtr head, int target) {
while(head != NULL) {
if(head->item == target) {
return head;
}
head = head->link;
}
return NULL;
}
Hope this helps.
Get Answers For Free
Most questions answered within 1 hours.