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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started