Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I just need help with this method, thank you in advance ! // Q2 : sort (10 points) // This function is used to sort

image text in transcribed

image text in transcribed

I just need help with this method, thank you in advance !

// Q2 : sort (10 points) // This function is used to sort the list(array of structs) numerically by book ID. // Parse the list and compare the book IDs to check which one should appear before the other in the list. // Sorting should happen within the list. That is, you should not create a new array of structs having sorted books. [// Hint: Use a temp struct (already declared) if you need to swap two structs in your logic // the number of books currently stored in the list (initialized to 0) int count = 0; unsigned int bookId; void sort() { struct libraryRecord libraryTemp; // Enter code here // needed for swapping structs. Not absolutely necessary to use. // display message for user to check the result of sorting. printf(" Book list sorted! Use display option 'd' to view sorted list. "); Enter your selection: a: add a new book d: display book list r: remove a book from list s: sort book list by ID q: quit S Book list sorted! Use display option 'd' to view sorted list. Enter your selection: a: add a new book d: display book list r: remove a book from list s: sort book list by ID q: quit d Book Title: Sapiens Author Name: Yuval Book Type: Nonfiction Book ID: 1 Aisle number: 1 Book Title: The Alchemist Author Name: Paulo Book Type: Fiction Book ID: 2 Aisle number: 2 Book Title: A Promised Land Author Name: Barack Obama Book Type: Nonfiction Book ID: 3 Aisle number: 3 // Q2 : sort (10 points) // This function is used to sort the list(array of structs) numerically by book ID. // Parse the list and compare the book IDs to check which one should appear before the other in the list. // Sorting should happen within the list. That is, you should not create a new array of structs having sorted books. [// Hint: Use a temp struct (already declared) if you need to swap two structs in your logic // the number of books currently stored in the list (initialized to 0) int count = 0; unsigned int bookId; void sort() { struct libraryRecord libraryTemp; // Enter code here // needed for swapping structs. Not absolutely necessary to use. // display message for user to check the result of sorting. printf(" Book list sorted! Use display option 'd' to view sorted list. "); Enter your selection: a: add a new book d: display book list r: remove a book from list s: sort book list by ID q: quit S Book list sorted! Use display option 'd' to view sorted list. Enter your selection: a: add a new book d: display book list r: remove a book from list s: sort book list by ID q: quit d Book Title: Sapiens Author Name: Yuval Book Type: Nonfiction Book ID: 1 Aisle number: 1 Book Title: The Alchemist Author Name: Paulo Book Type: Fiction Book ID: 2 Aisle number: 2 Book Title: A Promised Land Author Name: Barack Obama Book Type: Nonfiction Book ID: 3 Aisle number: 3

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_2

Step: 3

blur-text-image_3

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 Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

8. Provide recommendations for how to manage knowledge.

Answered: 1 week ago

Question

5. Develop a self-management module for a training program.

Answered: 1 week ago