Posted: October 16th, 2022

Do not hard code

Place your order now for a similar assignment and have exceptional work written by our team of experts, At affordable rates

For This or a Similar Paper Click To Order Now

Take several mystery sorting algorithms and determine which ones they are by experimentation.
The object file mysterysorts.o contains six sorting algorithms, which you can use by calling the
mysterySort function with an array, its length, and an integer between 0 and 5 to indicate which
algorithm to use. The function is designed to take an array of numbers and order the elements into
ascending order using the particular algorithm. More specifically, the algorithms used are:
Bubble sort
Insertion sort
Selection sort
Heap sort
Merge sort
Quicksort (where the first element of the array is used as the pivot for partitioning.)
Your job as the sorting detective is to figure out which algorithm is implemented by each mystery sort.
Below are some techniques you may use.
First, you can interrupt the sort and observe how the values are being moved around the array. Read
the comments of the provided header file mysterysorts.h that tells you how you can control the
number of steps performed by the algorithm. You should then check whether the behavior of the
algorithm matches the known behavior and invariants of the particular sorting algorithms. You must
use randomly generated arrays for these tests, not hard coded arrays.
Secondly, you can time the sorting algorithms and get an overall idea of their performances. A way to
measure elapsed system time for programs is to use function gettimeofday(). If you record the
starting and finishing times in the timeval structures start and finish, you can compute the
time elapsed in microseconds as demonstrated in the starter file named demo.c .
To perform this task you will need to complete the time_category and classify functions in the
file detective.c . They should take a number for algorithm to select and use one or more calls to
mysterySort with that algorithm number to determine which algorithm it is using. Do not hard code
your conclusions of which algorithm is which, but write code to analyze the algorithm’s behavior and
determine which algorithm it is. Grading tests will be run with the algorithms being assigned different
numbers.
2
Note that the object file mysterysorts.o is compiled on the CS department servers under Linux, so
it may not be compatible with your home machine.

For This or a Similar Paper Click To Order Now

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00