Question: 8) Sorting - C++ You have this function that sorts any vector of char data: void good_bubble(vector & data, vector ::size_type start, vector ::size_type end)

8) Sorting - C++

You have this function that sorts any vector of char data:

    void good_bubble(vector & data, vector::size_type start,                                          vector::size_type end)    {            vector::size_type loop{0}, cur;            bool done{false};            while (loop <= end-start+1 && !done)            {                    done = true;                    for (cur = start; cur <= end-1-loop; ++cur)                    {                            if (data[cur] > data[cur+1])                            {                                    swap(data[cur], data[cur+1]);                                    done = false;                            }                    }                    ++loop;            }            return;    }

But now you have to sort Date objects! As luck would have it,the Date class provides the method:

    bool Date::greater(const Date & other) const;

Please show your changes to only the lines from above that wouldneed to change to make your overload of good_bubble sort a vectorof Date objects.

Step by Step Solution

3.45 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Updated code that would so... View full answer

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 Programming Questions!