Dana Vrajitoru
C243 Data Structures

C243/A594 Homework 10

Due date: Wednesday, November 20, 2019.

Ex. 1. This is a team homework.

Implement a sorting algorithm that is O(n log2 n) on average, such as Quicksort, Merge Sort, Heapsort. Your programs will the tested on a number of randomly generated arrays of various sizes (the same arrays for everyone). The fastest algorithm in the entire class turned in on time receives 5 extra credit points. Do not use the function sort from the STL, or any other function from the STL except for the swap if you want.

The main program should do the following, in this order:

To test the algorithm you can generate the array using a random number generator, only change it before you turn the program in. This is designed so that we can use the redirection to input the array from a file. Here is an example of a test file with 500 numbers to sort:
test500.txt

In the test, the integers can be from the entire integer range, even though in the file it looks like the are in the range 0 to 9999.

Timing. Here's some information about timing your sorting function. Note that this might not work just like this on Windows or Mac - you'd have to look for the appropriate header on that system. First, include this header file:

#include <sys/time.h>
Then declare the following variables:
struct timeval before, after;
double timing;
Before the sorting function:
gettimeofday(&before, 0);
After the function call:
gettimeofday(&after, 0);
timing = (double) ((double)after.tv_sec +
                   (double)after.tv_usec/(1000*1000)) -
         (double) ((double)before.tv_sec +
                   (double)before.tv_usec/(1000*1000));
The timing is your final timing of the sorting function.

Github Project. Create a GitHub project for this assignment and add all the team members as collaborators. Submit a link to the GitHub project to Canvas.

Turn in to Canvas: Submit the link to the GitHub project and the name of the other team members to Canvas.