Illustrate the growth of the algorithm by: i. providing a table that reports the growth of the sorting algorithm in the implementation above; and ii. plot a graph to illustrate the growth of the sorting algorithm. To illustrate the growth of your sorting algorithm, run the program with at least the following n values (n represents the number of order ids that was generated): 1,000; 5,000;32,000; 512,000; 1,000,000. The growth of the algorithm is typically measured in millisecond (ms) or microsecond (µs) or nanosecond (ns). The growth rate of your sorting algorithm may vary due to your processor speed, memory capacity and etc. Therefore, to illustrate the consistency of the growth rate of your program, you will need to perform and report a minimum of 5 trial runs on each of the n values. You may then take the average of the running time for plotting the graph and for the discussion in the section below.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Illustrate the growth of the algorithm by:
i. providing a table that reports the growth of the sorting algorithm in the
implementation above; and


ii. plot a graph to illustrate the growth of the sorting algorithm.
To illustrate the growth of your sorting algorithm, run the program with at least the following n values (n represents the number of order ids that was generated): 1,000; 5,000;32,000; 512,000; 1,000,000. The growth of the algorithm is typically measured in millisecond (ms) or microsecond (µs) or nanosecond (ns).


The growth rate of your sorting algorithm may vary due to your processor speed, memory capacity and etc. Therefore, to illustrate the consistency of the growth rate of your program, you will need to perform and report a minimum of 5 trial runs on each of the n values. You may then take the average of the running time for plotting the graph and for the discussion
in the section below.

 

 

 

#include<bits/stde++.h>
void mergeSort(string a[], string b[], int left, int right) {
cout<<originalorderid[i]<<"t\t"<<originalc-
ost[i]<<endl;
int mid;
if(left < right) {
mid = left + (right-1)/2;
mergeSort(a,b,left,mid);
mergeSort(a,b,mid+1,right);
merge(a,b,left,mid,right);
using namespace std;
break;
for(int i= 0; i< n; it+) {
cout<<orderid[i]<<"t\t"<<cost[i]<<endl;
void merge(string a[], string b[], int left, int mid, int right) {
case 3:
int nL = mid - left + 1;
int nR = right - mid;
string leftA[nL], rightA[nR], leftB[nL], rightB[nR];
for(int i = 0; i<nL; i++) {
leftA[i] = a[nL+i];
leftB[i] = b[nL+i]:
}
for(int i = 0; i< nR; i++) {
rightA[i] = a[mid+i+1];
rightB[i] = b[mid+i+1];
}
int i = 0, j = 0, k = left;
while(i< nL &&j<nR) {
if(leftA[i] <= rightA[j]) {
a[k] = leftA[i];
b[k] = leftB[i];
i++;
}
else {
a[k] = rightA[j]:
b[k] = rightB[j];
j++;
k++;
break;
w = false;
break;
w = false;
case 4:
}
}
default:
int menu) {
int ch;
cout<<"1. Time for sorting\n2. Unsorted List\n3, Sort'n4, Exit'nEnter Choice: ":
cin>>ch;
return ch:
}
return 0;
}
End of document
int main() {
int n;
cout<<"Enter number of order ids: ";
cin>>n;
srand((unsigned) time(0));
string orderid[n], cost[n], originalorderid[n], originalcost[n];:
for(int i= 0; i<n; i++) {
int randNum = (rand()%n)+1;
orderid[i] = "FD" + to_string(randNum);
originalorderid[i] = orderid[i];
float a = 1.0;
float randCostNum = (float(rand())/float(RAND_MAX) * a);
randCostNum = (int)(randCostNum * 100 + 0.5);
randCostNum = (float)randCostNum / 100;
cost[i] = "RM" + to_string(randCostNum);
originalcost[i] = cost[i];
}
time_t start, end;
time(&start);
ios_base:sync_with_stdio(false);
mergeSort(orderid, cost, 0, n-1);
time(&end);
double timeTaken = double(end - start);
bool w = true;
while(w) {
int choice = menu);
switch(choice) {
case 1:
}
}
while(i< nL) {
a[k] = leftA[i];
b[k] = leftB[i];
i++;
k++:
}
while(j < nR) {
a[k] = rightA[j];
b[k] = rightB[j];
j++;
k++;
}
cout << "Time taken by merge sort is : "<< timeTaken << setpreci-
sion(5);
cout <<" sec "<< endl:
break;
for(int i = 0; i<n; i++) {
}
case 2:
Transcribed Image Text:#include<bits/stde++.h> void mergeSort(string a[], string b[], int left, int right) { cout<<originalorderid[i]<<"t\t"<<originalc- ost[i]<<endl; int mid; if(left < right) { mid = left + (right-1)/2; mergeSort(a,b,left,mid); mergeSort(a,b,mid+1,right); merge(a,b,left,mid,right); using namespace std; break; for(int i= 0; i< n; it+) { cout<<orderid[i]<<"t\t"<<cost[i]<<endl; void merge(string a[], string b[], int left, int mid, int right) { case 3: int nL = mid - left + 1; int nR = right - mid; string leftA[nL], rightA[nR], leftB[nL], rightB[nR]; for(int i = 0; i<nL; i++) { leftA[i] = a[nL+i]; leftB[i] = b[nL+i]: } for(int i = 0; i< nR; i++) { rightA[i] = a[mid+i+1]; rightB[i] = b[mid+i+1]; } int i = 0, j = 0, k = left; while(i< nL &&j<nR) { if(leftA[i] <= rightA[j]) { a[k] = leftA[i]; b[k] = leftB[i]; i++; } else { a[k] = rightA[j]: b[k] = rightB[j]; j++; k++; break; w = false; break; w = false; case 4: } } default: int menu) { int ch; cout<<"1. Time for sorting\n2. Unsorted List\n3, Sort'n4, Exit'nEnter Choice: ": cin>>ch; return ch: } return 0; } End of document int main() { int n; cout<<"Enter number of order ids: "; cin>>n; srand((unsigned) time(0)); string orderid[n], cost[n], originalorderid[n], originalcost[n];: for(int i= 0; i<n; i++) { int randNum = (rand()%n)+1; orderid[i] = "FD" + to_string(randNum); originalorderid[i] = orderid[i]; float a = 1.0; float randCostNum = (float(rand())/float(RAND_MAX) * a); randCostNum = (int)(randCostNum * 100 + 0.5); randCostNum = (float)randCostNum / 100; cost[i] = "RM" + to_string(randCostNum); originalcost[i] = cost[i]; } time_t start, end; time(&start); ios_base:sync_with_stdio(false); mergeSort(orderid, cost, 0, n-1); time(&end); double timeTaken = double(end - start); bool w = true; while(w) { int choice = menu); switch(choice) { case 1: } } while(i< nL) { a[k] = leftA[i]; b[k] = leftB[i]; i++; k++: } while(j < nR) { a[k] = rightA[j]; b[k] = rightB[j]; j++; k++; } cout << "Time taken by merge sort is : "<< timeTaken << setpreci- sion(5); cout <<" sec "<< endl: break; for(int i = 0; i<n; i++) { } case 2:
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Eight puzzle problem
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education