Question: c++ Given the following struct to store information about books: struct Book string title; int year; }; And the following bubble sort code from class:

c++
c++ Given the following struct to store information about books: struct Book

Given the following struct to store information about books: struct Book string title; int year; \}; And the following bubble sort code from class: void bubblesort (int list [], int size) \{ bool swapped = false; do \{ for (int i=0;i list [i+1]){ Ifswap int temp = list[i]; list[i] = list[i+1] list[i+1] = temp; swapped = true; 3 ) 7 while (swapped == true); \} Rewrite the bubble sort function to do the following: A. Fix the bugl! B. Make it sort an array of Book-structs on the year field, in decreasing order (highest year (most recent) to lowest year). - Hint: you can use the assignment operator on an entire struct, you don't need to do it field by field (member by member). C. Make it output a count of how many times it compares (a field from) one array element to another. It should output the count only once. - Hint: do not count only when the comparison is true, but whenever the comparison is made (true or false)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!