You have been hired as a consultant

People have learned that after seven weeks in this cs330 class, and a few semesters at IIT, you're good at discrete mathematics and programing, and in need of money too. Therefore the Silver Bullet Corporation (CBO) is asking you to help them as a computer consultant. The company has recently lost their programmer, and they need some help in assessing some sorting programs written by the nephew of the company's president. The mentioned nephew is himself a Compuer Science student at a large University in the Chicagoland area.

The problem description is included on the attached memorandum from CBO.

What You'll Turn In

  1. A well commented listing of the C programs that do the sorting.
  2. Timing from the programs runs for array sizes of 100 to 2000 in steps of 100
  3. A memo with your assesment of the problem. In one or two paragraphs indicate what growth function best characterizes the time growth of the sorting algorithms in the average case; do this also for the cases when the arrays to be sorted are sorted or sorted in reversed order. Direct the memo to Mr. Bigan.


  1. Use the the clock() function that comes with timer.h
  2. Don't turn in running times of zero! They do not mean we can sort small arrays in no time (though we'd like to): the fact is caused by the granularity of the computer's timer. If the sorting is very fast we may not accumulate at least one CLK_TCK of time. The solution is to perform several sorting iterations, measure the time, and divide it by the number of arrays sorted. In doing so you'll have the trouble of generating random numbers inside the timer loop; since we don't want to include the random number generation time in the sorting time, you will have to take care of this and subtract the generation time from the sorting time.
  3. Don't include the print statements in the timing: we're only concerned with the sorting performance.

Silver Bullet Corporation - Office of the President

DATE: October 5, 1995

TO: Bob Bigan, Director R&D

FROM: John Clyde

SUBJECT: Basil's Sorting Algorithms

I am unpleasantly surprised to learn that our programmer has left SBC. I find disturbing that we can not keep programmers with our current competitive wage of $4.36 per hour. This resignation comes at a very difficult time, since I am interested in implementing the sorting algorithms developed by my nephew Basil. We need to assess the algorithms before we put them in production mode. Hire a consultant if necessary to complete the task.

The question to be answered is: "What is the growth rate (with respect to time) of Basil's sorting algorithms?". Since the growth rate of our currently used sorting algorithm is cubical, anything better than that will be good for us.

Your help in this matter is highly appreciated.

Silver Bullet Corporation

DATE: October 1, 1995

TO: Bob Bigan, Director R&D

FROM: Mike Donald, Programmer

SUBJECT: Basil's Sorting Algorithms

Since I am leaving the company, I want to pass on some information concerning the sorting programs developed by Mr. Clyde's nephew Basil.

The programs are written in C and utilize sorting algorithms I am not familiar with. I have implemented Basil's code and it seems to be sorting arrays properly.

Basil's work consists of the following:

I did start program modifications to assess the timing of the programs. However, I haven't had time to complete my work. I've attached a copy of the code as it currently exists. A zip-ed version also exists and you can download it if your web browser can.

It seems like Mr. Clyde wants to know what the time growths of the sorting programs is . He would like the algorithms assessed for array sizes of 100 to 2000 in steps of 100. Once these timings are complete he would like the results compared to the standard growth functions (constant, logn, n, nlogn, n^2, n^3, 2^n) and a determination made as to which growth rate function the sorting algorithms follow.

Should there be any questions on the programs, you can contact me at my new employer Donalds.


This programming assignment has been inspired by Chuck Pheatt.