Assume entries in a linked list are of type struct listrec: struct listrec { struct listrec *prev;
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.
Head and tail are two pointers that point to the beginning and end of the linked list, respectively.
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss