Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

return false; 5. Implement the following function as a new function for the link

ID: 3595422 • Letter: R

Question

return false; 5. Implement the following function as a new function for the linked list toolkit. (Use the usual node definition with member variables called data and link.) (20 pts) size t count 42s (const node* head ptr): 7/ Precondition: head ptr is the head pointer of a linked list. // The list might be empty or it might be non-empty. // Postcondition: The return value is the number of occurrences /1 of 42 in the data field of a node on the linked list. // The list itself is unchanged. tion Cherk the precondition as much as

Explanation / Answer

size_t count_42s(const node* head_ptr){

    node *temp;
    temp = head;
    size_t count = 0;

    while (temp != NULL){
         if (temp->data == 42)
            count++;
         temp = temp->next;

    }
    return count;
}