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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started