CSCI 131 Techniques of Programming--Spring 2014

    Home | | Schedule | | Assignments | | Lectures | | Resources

    Solution to Lab 9

    Sorting and Searching

    Question 1 List the private data members of the Employee class.

    char name[30]; float hourlyPay; int idNum;

    Question 2 Looking only at the employee.h header file, which public member function(s) do not change any of the members variables? How do you know this?

    GetID() and Print(), because they are declared as const methods.

    Question 3 What important thing do you notice about the list after the first pass of Bubble Sort?. (This is something that would be true for any list we were sorting, not just the example in Figure 9.1.)

    That the largest item is at the end of the list and does not need to be moved again during further sorting.

    Question 4 Using a series of pictures like the ones in Figures 9.1 and 9.2 show which pairs are compared in the third, fourth and fifth passes of Bubble Sort. jUsing pictures like the ones in Figures 9.1 and 9.2 show which pairs are compared in the third, fourth and fifth passes of Bubble Sort.

    Question 5 How many times will the refined algorithm pass through the list in Figure 9.1?

    4 times

    inventory.cc


    Home | | Schedule | | Assignments | | Lectures | | Resources



    CSCI 131: Techniques of Programming
    Last Modified: April 10, 2014
    Page Expires: October 12, 2014