Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please, explain your work Problem 2 (30 points): Manipulating Linked Lists Prof. Lumetta needs your help! He has gathered his books into a linked list

please, explain your work image text in transcribed
image text in transcribed
Problem 2 (30 points): Manipulating Linked Lists Prof. Lumetta needs your help! He has gathered his books into a linked list of book_t structures, defined as shown below. The next field links one book to the next in the list. typedef struct book_t book_t; struct book_t { char* title; char* author; char* call_number; int due_date; book_t* next; Prof. Lumetta needs to separate a linked list of books" (book_t's) into two separate lists based on their due dates (the due date field). Help Prof. Lumetta by completing the function on the following page. The function signature is as follows: book_t* collect_books (book_t** listp, int due_by); The function takes two parameters: listp a pointer to a pointer to the first book in the original linked list of books due_by-the date used to separate the list The function must separate the original list into two separate linked lists, each correctly terminated, as follows: All books with due date field less than or equal to due_by should be removed from the original list and collected into a new list. The order of these books in the new list does not matter. The function must return a pointer to the first book in the new list. Any book with a due date larger than due_by should remain in the original list. The order of these remaining books must not change. The function must update the value to which listp points to indicate the first book in the original list with a due_date larger than due_by. Problem 2, continued: A structure definition replicated for your convenience / typedef struct book_t book_t; struct bookt char* title; char* author; char* call number; int due_date; book to next; * Complete the function by filling in the blanks. */ book_t* collect_books (book_t** listp, int due_by) book_t* collected; book_t* book; while book -*listpi if (due_by listp - } else { "listp collected

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

5. Structure your speech to make it easy to listen to

Answered: 1 week ago

Question

1. Describe the goals of informative speaking

Answered: 1 week ago