UCR CS 14: Introduction to Data Structures and Algorithms

Summer Quarter 2003 / Class webpage




Lab 07

Remember:

In this lab, we will work with sorting algorithms performance. First, download the files: array.h, simplearray.h, sorting.h, and testSorting.cc.

File testSorting.cc contains:

  • Function fill_random that receives an array and populates it with random values.
  • Function runSorting that receives an array size, an integer, and an algorithm flag. This function creates an array with the given size, and run the algorithm indicated by the flag the given number of times.
  • Function main calls function runSorting with different input sizes for all sorting algorithms presented in sorting.h

    File sorting.h contains two versions of the algorithm bubblesort, and one of selection. At the end of this file, you have just the header for the algorithm insertion.

    These files use an ADT array defined in array.h and implemented in simplearray.h.


    Turn-in

    4 points possible

    4 points possible




    Bonus, more 3 points

    About bonus credit. This part of your work may give you a chance to increase your grade. If you already have an A, this may help you to add a beautiful A+ in your records. Note that you only get the bonus point if you complete the turn-in part.

    1. In a file called performance, include the performance data you collected (each in the form of a table), compare the actual performance of these algorithms to their asymptotic complexity, and explain your "theories" (if you have any) on why certain implementations are faster or slower that others.

    2. Extend testSorting.h and include two functions: fill_ascending and fill_descending, which populate an array with numbers in ascending and descending order, respectively. Then, extend function runSorting for running the algorithms considering these two kind of arrays. Plot these results in another graph.

    3. Extend sorting.h and include other sorting algorithms as heapsort, quicksort, and mergesort. Then, extend function runSorting for running these algorithms. Plot these results in another graph.