Question
Assume entries in a linked list are of type struct listrec : struct listrec { struct listrec *prev; float value; struct listrec *next; }; listrec
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.
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