UMBC CMSC202, Computer Science II, Spring 1998,
Sections 0101, 0102, 0103, 0104 and Honors
Tuesday February 10 1998
- A Book on C: 6.7 - 6.9
- Programming Abstractions in C: 7.1 - 7.4
Handouts (available on-line):
Sorting, Sorting Routines.
- Using the assert() function.
- Selection Sort
Program to generate
binary file of random integers. Note the use of the
fstat() function to find the size of a file.
- Program and
header file for some support
routines to be used with our sorting routines.
- A makefile keeps
everything up to date.
- Program to
test Selection Sort and sample
run. Note the use of "make -e" to turn off the
debugging statements. It took over 5.2 hours to
sort 400,000 integers.
- Insertion Sort
can be somewhat faster than Selection Sort.
Our test program and
sample run show that
it took only 3.2 hours to sort 400,000 integers.
- A graph of the running
times of our experiments with Selection Sort and Insertion
Sort show that the running times are proportional to
n2, where n is the number of items.
By extending these curves
we estimate that the running times to sort 1.6 million
integers would take over 83 hours (about 3.5 days) and
over 51 hours (about 2 days) for Selection Sort and
Insertion Sort respectively.
- Merge Sort uses
a divide-and-conquer strategy and solves the sorting problem
by recursion. Our test program
and sample runs show that
Merge Sort takes only 23 seconds to sort 1.6 million items.
23 Mar 1998 13:06:45 EST
to Spring 1998 CMSC 202 Section Homepage