Question: In C++: size_t list_length (const node* head_ptr) //Precondition: head_ptr is the head pointer of a linked list //Postcondition: The value returned is the number of
In C++: size_t list_length (const node* head_ptr)
//Precondition: head_ptr is the head pointer of a linked list //Postcondition: The value returned is the number of nodes in the linked list.
//Library facilities used: cstdlip
{
const node *cursor;
size_t answer;
answer = 0;
for (cursor = head_ptr; cursor != NULL; cursor = cursor link())
++answer; return answer; }
1.b Using comments explain each line of the code (before the line of code), THEN
1.c Sketch out the nodes, data and pointers for each line of code (by hand is fine)
1.d In pseudo code explain the pattern for traversing the linked list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
