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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!