void sort (int* a, int n);
This procedure and its subroutines should reside in a file sort.c, which should not contain a main function. Your procedure will be evaluated on 1,000,000-element arrays, with values between -5,000,000 and 5,000,000.
You may download an example sort.c file with insertion sort; note that this example sorting is too slow for 1,000,000-element arrays, and you should implement a faster algorithm. You may use the tester.c file for testing your code; it includes procedures for generating random arrays and checking the correctness of sorting. After you implement a sorting procedure, put tester.c and sort.c in the same directory and compile them:
gcc -O -funroll-loops -o tester tester.c
If you then run tester, it will apply your procedure to ten arrays,
and output the number of correctly sorted arrays and the average sorting
time. When debugging, you may control the array size, range of values,
and number of tests, by re-defining the following constants in tester.c:
SIZE | size of the array a | ||
MIN | lower bound for the range of values | ||
MAX | upper bound for the range of values | ||
TESTS | number of arrays to be sorted |
Sorting Competition: Cheng, Fink
You do not need to submit a print-out of your code or a written report. Note that the code is due by 9:30am even if your machine or network is down. Try to e-mail it in advance, to ensure that computer "emergencies" do not affect your submission. If you e-mail your code within 48 hours after the deadline, then you may earn up to five points for correct sorting, but you will not enter the speed competition.
First place | 30/n points | ||
Second place | 20/n points | ||
Third place | 10/n points |
If the speed of your program is within the factor of five from the first place, you will get additional five points. For example, suppose that your group consists of two members, your program has correctly sorted all ten arrays, it has earned the third place in the competition, and its speed is within the factor of five from the first place; then, your total grade is 5 + 10/2 + 5 = 15.