Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume entries in a linked list are of type struct listrec: struct listrec { struct listrec *prev; float value; struct listrec *next; }; listrec *head,

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.

Step by Step Solution

3.52 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

Source Code include include creating a structure for a node struct listrec struct listrec prev float ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Structures and Algorithm Analysis in Java

Authors: Mark A. Weiss

3rd edition

132576279, 978-0132576277

More Books

Students also viewed these Programming questions

Question

3. If possible, break the presentation into clear steps or stages.

Answered: 1 week ago