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

Assume entries in a linked list are of type struct listrec : struct listrec { st

ID: 3801370 • Letter: A

Question

Assume entries in a linked list are of type struct listrec:

struct listrec

{

            struct listrec    *prev;

float                 value;

            struct listrec    *next;  

};

listrec *head, *tail;

Write a main() routine in which the user is asked the number of nodes to create in the list (number greater than or equal to zero) then create the following type of linked list (use a loop to initialize list) based on the number of nodes requested:

Write a function called listSize that takes two input parameters - the pointer head OR tail plus a parameter of which direction to traverse - to traverse the linked list and return the number of elements in the list. Write another function printForwardElem that prints out the value of every element of the linked list in sequence starting from head forward to the end of the list. Write a third function printBackwardElem that prints out the value of every element of the linked list in sequence starting from tail backward to the beginning of the list. Design your driver to test these three functions.

Hint: head and tail are two pointers that point to the beginning and end of the linked list, respectively.

Explanation / Answer

int P , Q ,R , S

reverse( S )

{

P = Q = NULL;

R = S;

while( R!= NULL)

{

P = Q;

Q = R;

R = R -> NEXT;

Q -> NEXT = P;

}

S = Q;

return( S )

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote