UMBC CMSC202, Computer Science II, Spring 1998,
Sections 0101, 0102, 0103, 0104 and Honors
Tuesday February 10 1998
Assigned Reading:
 A Book on C: 6.7  6.9
 Programming Abstractions in C: 7.1  7.4
Handouts (available online):
Introduction to
Sorting, Sorting Routines.
Topics Covered:
 Using the assert() function.
Program and
sample run.
 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
n^{2}, 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 divideandconquer 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.
Last Modified:
23 Mar 1998 13:06:45 EST
by
Richard Chang
Back up
to Spring 1998 CMSC 202 Section Homepage