[Solved]Include Include Include Include Using Namespace Std Template Void Quicksort T Int Size Pre Q37163981
#include <iostream>#include <cstdlib>#include <cassert>#include <algorithm>using namespace std;template <typename T>void quick_sort (T* a, int size);// precondition: a is not NULL// postcondition: a is sorted in non-decreasing orderint main (){ int size = 100; int* a = create_array (size); clock_t start_time = clock(); quick_sort (a, size); clock_t stop_time = clock(); cout << double(stop_time – start_time ) / (double)CLOCKS_PER_SEC<< ” seconds.” << endl; assert (is_sorted (a, size)); delete a; return EXIT_SUCCESS; }
/**********************************************************/
To improve the reliability of our results, we will perform eachexperiment 10 times and use the average of these 10 values as ourresult. Specifically, you need to do the following:
-
run the following 10 times
-
create an array of size 10000 of random integers
-
measure how long it takes the quick sort which uses the firstelement of the subarray as the pivot to sort this array
-
measure how long it takes the quick sort which uses the medianelement of the first 3 elements to sort the same array
-
discuss the difference in the efficiencies of these 2approaches
-
-
perform this same experiment using an array of size 100000
Please use this code as your starting place.
Expert Answer
Answer to #include #include #include #include using namespace std; template void quick_sort (T* a, int size); // precondition: a … . . .
OR

