Question
Code the merge sort in C++. Make sure to base your code on the pseudocode in the book (not on things that you find on
Code the merge sort in C++. Make sure to base your code on the pseudocode in the book (not on things that you find on the internet). Create 2 .cpp files: sortMain.cpp and mergeSort.cpp. Below is a template that you should use:
//---------------------------------------------------------------------- //file: sortMain.cpp #include#include extern void mergeSort ( int A[], int n ); using namespace std; int main ( int argc, char* argv[] ) { . . . } //---------------------------------------------------------------------- //file: mergeSort.cpp void mergeSort ( int A[], int n ) { . . . } //free to define other functions of your own.
Run the sort on input sizes of 10, 100, 1000, 10000, 100000, 200000, 300000, 400000, 500000, and 1000000 of random values. Depending upon the speed of your computer, you may only be able to run one or a few sorts for larger input sizes. Report the array size n (N), number of test iterations (#), total elapsed time (tElapsed), total CPU time (tCPU), average CPU time (avgCPU) for insertion sort in a table like the following:
merge sort | ||||
N | # | tElapsed | tCPU | avgCPU |
10 | ||||
100 | ||||
1000 | ||||
10000 | ||||
100000 | ||||
200000 | ||||
300000 | ||||
400000 | ||||
500000 | ||||
1000000 |
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