Lab 10
comp 125-609, Goldwasser
Tuesday, 9 November 1999
Purpose: How Fast are These Sorting Methods?
In today's lab, our goal is to better understand the time used by four
sorting methods which we have seen: Selection Sort, Insertion
Sort, Bubble Sort, and Merge Sort.
In the first part of the lab, we will run experiments on these sorting
methods for various size arrays, recording the amount of time which
each sort uses for a given array.
In the second part of the lab, we will use graphics to display the results.
The time required by these methods depends greatly on the specific
code used to implement the high-level ideas. We will provide you with
a program executable, which is an enhanced version of the program used
in last week's lab. Please begin by down-loading
www.cs.luc.edu/~mhg/comp125/labs/timesort.exe
Although you will not need the full functionality of this program in
today's lab, please familiarize yourself with the program now, as this
program will also be the basis for the next homework assignment.
When running the program, the following settings may be chosen by the user:
Now let's gather statistics. Run each of the four sorts on each of
the following array sizes: 500, 1000, 2000, 4000, 8000. Record the
number of seconds for each experiment in the table below:
Method |
500 |
1000 |
2000 |
4000 |
8000 |
Selection |
|
|
|
|
|
Insertion |
|
|
|
|
|
Bubble |
|
|
|
|
|
Merge |
|
|
|
|
|
Now let's use the Visual Basic graphics to give us a quick-and-dirty
line graph for displaying our data. Create a picture window and set
up the coordinates with the command
Picture1.Scale (-1000,120)-(10000,-20)
at run time. Draw the axes by making two lines:
Picture1.Line (0,0)-(8000,0)
Picture1.Line (0,0)-(0,120)
Next label both axes with relevant tick marks. Finally, for each
sort, pick a unique color, and graph the five data points for that
sort connecting the points with lines in the graph.
This lab is due before leaving class today. When you have completed
both parts of the program, please call me over to your computer to see
your graph and data.