Question: Using C++ - Insertion Sort - Quick Sort - Merge Sort Test each sort algorithm using an array of 10000 elements(use random numbers). Display the

Using C++

- Insertion Sort

- Quick Sort

- Merge Sort

Test each sort algorithm using an array of 10000 elements(use random numbers). Display the time difference using the time function for each sort algorithm. Time it before the function sorting is called.

The following code was posted by Royden Luckey:

Here is how to use current time.

#include ... needed.

void timer()

{

clock_t startTime;

clock_t endTime;

double runningTime;

start = clock();

//RUN THE THING YOU WANT TO TIME HERE!!!

end = clock();

runningTime = double(endTime) - double(startTime); //running time is now number of clock ticks on your system

runningTime /= CLOCKS_PER_SECOND; //runningTime is now the number of seconds in real time

cout << " It took " << runningTime << " seconds to run the test. " << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!