SlideShare a Scribd company logo
1 of 7
Download to read offline
Please help me fix the following errors in red. I attached the code below for each file that
contains an error. I did not attach the SortUtil.h file because it did not contain any errors.
SortProfiler.cpp:
#include <iostream>
#include <cstdlib>
#include <chrono>
#include <iomanip>
#include "arrayutil.cpp"
#include "SortUtil.cpp"
using namespace std;
using namespace std::chrono;
int main(int argc, char **argv)
{
int *iArray1, *iArray2, *iArray3;
double *dArray1, *dArray2, *dArray3;
long bTime, sTime, qTime;
int size[] = {100, 500, 1000, 5000, 10000, 50000, 100000};
srand(time(NULL));
double *testArray = new double [50];
cout<<"***Testing Selection Sort***"<<endl;
cout<<"Original Array:"<<endl;
ArrayUtil::genRandArray(testArray,50);
ArrayUtil::printArray(testArray,0,49,5);
cout<<endl;
SortUtil::selectionSortDouble(testArray,50);
cout<<"Sorted Array:"<<endl;
ArrayUtil::printArray(testArray,0,49,5);
cout<<endl;
cout<<"***Testing Bubble Sort***"<<endl;
cout<<"Original Array:"<<endl;
ArrayUtil::genRandArray(testArray,50);
ArrayUtil::printArray(testArray,0,49,5);
cout<<endl;
SortUtil::bubbleSortDouble(testArray,50);
cout<<"Sorted Array:"<<endl;
ArrayUtil::printArray(testArray,0,49,5);
cout<<endl;
cout<<"***Testing Quick Sort***"<<endl;
cout<<"Original Array:"<<endl;
ArrayUtil::genRandArray(testArray,50);
ArrayUtil::printArray(testArray,0,49,5);
cout<<endl;
SortUtil::quickSortDouble(testArray,0,49);
cout<<"Sorted Array:"<<endl;
ArrayUtil::printArray(testArray,0,49,5);
cout<<endl;
cout<<"Using Arrays with Random Doubles"<<endl;
cout<<setw(8)<<left<<"n"<<setw(16)<<left<<"selectionSort"<<setw(16)<<left<<"bubbleSort"<
<setw(12)<<left<<"quickSort"<<endl;
for(int i = 0; i < 50; i++) cout<<"-";
cout<<endl;
for (int i = 0; i < 7; i++)
{
dArray1 = new double[size[i]];
dArray2 = new double[size[i]];
dArray3 = new double[size[i]];
ArrayUtil::genRandArray(dArray1,size[i]);
ArrayUtil::arrayCopyDouble(dArray1, 0, dArray2, 0, size[i]);
ArrayUtil::arrayCopyDouble(dArray1, 0, dArray3, 0, size[i]);
auto start = high_resolution_clock::now();
SortUtil::selectionSort(dArray1,size[i]);
auto elapsed = high_resolution_clock::now() - start;
sTime = duration_cast<microseconds>(elapsed).count();
start = high_resolution_clock::now();
SortUtil::bubbleSort(dArray2,size[i]);
elapsed = high_resolution_clock::now() - start;
bTime = duration_cast<microseconds>(elapsed).count();
start = high_resolution_clock::now();
SortUtil::quickSort(dArray3,0,size[i]-1);
elapsed = high_resolution_clock::now() - start;
qTime = duration_cast<microseconds>(elapsed).count();
cout<<setw(8)<<size[i]<<setw(16)<<sTime<<setw(16)<<bTime<<setw(12)<<qTime<<endl;
delete[] dArray1;
delete[] dArray2;
delete[] dArray3;
}
cout<<endl<<endl;
return 0;
}
SortUtil.cpp:
#include <iostream>
#include <algorithm>
#include "SortUtil.h"
using namespace std;
static void arrayCopy (int source[], int sourceStart, int dest[], int destStart, int size)
{
for (int i = 0 ; i < size; i++)
{
dest [destStart + i] = source [sourceStart + i];
}
}
static int partition(int data[], int start, int end)
{
//implement this function
return 0;
}
static void merge(int data[], int first[],int sizeFirst, int second[], int sizeSecond)
{
int iFirst = 0;
int iSecond = 0;
int j = 0;
while (iFirst < sizeFirst && iSecond < sizeSecond)
{
if (first[iFirst] < second[iSecond])
{
data[j] = first[iFirst];
iFirst++;
}
else
{
data[j] = second[iSecond];
iSecond++;
}
j++;
}
arrayCopy(first, iFirst, data, j, sizeFirst-iFirst);
arrayCopy(second, iSecond, data, j, sizeSecond-iSecond);
}
/* sorting functions */
void SortUtil::bubbleSort(int data[], int size)
{
//implement this function
}
void SortUtil::selectionSort(int data[], int size)
{
//implement this function
}
void SortUtil::insertionSort(int data[],int size)
{
for (int i = 1; i < size; i++)
{
int next = data[i];
int j = i;
while (j > 0 && data[j-1] > next)
{
data[j] = data[j-1];
j--;
}
data[j] = next;
}
}
void SortUtil::quickSort(int data[], int start, int end)
{
//implement this function
}
void SortUtil::mergeSort(int data[], int size)
{
if (size <= 1)
return;
int *first = new int[size/2];
int *second = new int[size -size/2];
arrayCopy(data,0,first,0,size/2);
arrayCopy(data,size/2,second,0,size-size/2);
mergeSort(first,size/2);
mergeSort(second,size-size/2);
merge(data, first,size/2, second, size-size/2);
delete[] first;
delete[] second;
}
arrayutil.cpp
#include <cstdlib>
#include<iostream>
#include<iomanip>
#include <cstring>
#include <climits>
#include "arrayutil.h"
using namespace std;
template <typename T>
void ArrayUtil::arrayCopy(T a[], int i, T b[],int j, int numElems)
{
/*
for (int m = i; m < (i+numElems); m++)
{
b[j] = a[m];
j++;
}
*/
memcpy(&b[j],&a[i],sizeof(T)*numElems);
}
template <typename T>
void ArrayUtil::genRandArray(T* data, int size)
{
srand(time(NULL));
T factor = 1;
for (int i=0; i<size;i++)
data[i]=rand()%INT_MAX*factor;
}
template <typename T>
void ArrayUtil::genSortedArray(T* data, int size, bool ascending)
{
int i;
T factor = 1;
if (ascending)
{
for (i=0; i<size;i++)
data[i] = i*factor;
}
else
{
for (i=0; i<size;i++)
data[i]=size-i*factor;
}
}
template <typename T>
void ArrayUtil::printArray(T data[],int first,int last, int numPerLine)
{
for (int i = first; i <= last; i++)
{
cout<<fixed<<setprecision(4);
cout<<setw(10)<<data[i]<<" ";
if ((i - first + 1) % numPerLine == 0)
cout<<endl;
}
}
arrayutil.h
#include <cstdlib>
#include <iostream>
#ifndef ARRAYUTIL_H
#define ARRAYUTIL_H
using namespace std;
namespace ArrayUtil
{
/** copies numElems elements from array a to array b
* starting at position i in array a and starting at
* position j in array b.
* @param a - the source array
* @param i - the starting index in the source array
* @param b - the destination array
* @param j - the starting index in the destination array
* @param numElems - the number of elements to copy from
* the source array into the destination array.
*/
template <typename T>
void arrayCopy (T a[], int i, T b[], int j, int numElems);
/**
* This function fills an array with random numbers
* @param data - array
* @param size - size of the array
*/
template <typename T>
void genRandArray (T* data, int size);
/**
* This function fills an array with numbers in ascending or descending order
* @param data - array
* @param size - size of the array
*/
template <typename T>
void genSortedArray (T *data, int size, bool ascending);
/**
* Prints elements whose subscripts are in the range F to L
* of an array, numPerLine elements per line.
* @param data - an array containing data to be printed.
* @param first the first index of the array.
* @param last the last index of the array.
*/
template <typename T>
void printArray (T data[], int first, int last, int numPerLine);
}
#endif
GDB online Debugger | Compiler - Code, Compile, Run, Debug online C, C++ C Post a new
question 4 Compilation failed due to following error(s).

More Related Content

Similar to Please help me fix the following errors in red- I attached the code be.pdf

JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdffantasiatheoutofthef
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfravikapoorindia
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2YOGESH SINGH
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab ManualAkhilaaReddy
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfRahul04August
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory archana singh
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)Arun Umrao
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxJumanneChiyanda
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docxajoy21
 
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfPart 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfmohammadirfan136964
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docxajoy21
 

Similar to Please help me fix the following errors in red- I attached the code be.pdf (20)

SlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfSlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdf
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
 
C programs
C programsC programs
C programs
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab Manual
 
The purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdfThe purpose of this C++ programming project is to allow the student .pdf
The purpose of this C++ programming project is to allow the student .pdf
 
c programming
c programmingc programming
c programming
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
week-16x
week-16xweek-16x
week-16x
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
Array BPK 2
Array BPK 2Array BPK 2
Array BPK 2
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
 
Array and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptxArray and string in C++_093547 analysis.pptx
Array and string in C++_093547 analysis.pptx
 
Write a program that will test a name) method no sorting routine from.docx
 Write a program that will test a name) method no sorting routine from.docx Write a program that will test a name) method no sorting routine from.docx
Write a program that will test a name) method no sorting routine from.docx
 
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfPart 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docx
 

More from aarnnaenterprises

Write a brief research report (up to about 7 pages- not including titl.pdf
Write a brief research report (up to about 7 pages- not including titl.pdfWrite a brief research report (up to about 7 pages- not including titl.pdf
Write a brief research report (up to about 7 pages- not including titl.pdfaarnnaenterprises
 
Q28- NADH and NADPH are activated electron carrier molecules that func.pdf
Q28- NADH and NADPH are activated electron carrier molecules that func.pdfQ28- NADH and NADPH are activated electron carrier molecules that func.pdf
Q28- NADH and NADPH are activated electron carrier molecules that func.pdfaarnnaenterprises
 
Which of the following is NOT true about cholera- Caused by a virulent.pdf
Which of the following is NOT true about cholera- Caused by a virulent.pdfWhich of the following is NOT true about cholera- Caused by a virulent.pdf
Which of the following is NOT true about cholera- Caused by a virulent.pdfaarnnaenterprises
 
Which is not true of Chile's economic development model- The main driv.pdf
Which is not true of Chile's economic development model- The main driv.pdfWhich is not true of Chile's economic development model- The main driv.pdf
Which is not true of Chile's economic development model- The main driv.pdfaarnnaenterprises
 
Virus- Genome Classification- Describe (or draw) the path your virus t.pdf
Virus- Genome Classification- Describe (or draw) the path your virus t.pdfVirus- Genome Classification- Describe (or draw) the path your virus t.pdf
Virus- Genome Classification- Describe (or draw) the path your virus t.pdfaarnnaenterprises
 
The probabily that a pecton thas a cerian divoase is 002 Medical diagn.pdf
The probabily that a pecton thas a cerian divoase is 002 Medical diagn.pdfThe probabily that a pecton thas a cerian divoase is 002 Medical diagn.pdf
The probabily that a pecton thas a cerian divoase is 002 Medical diagn.pdfaarnnaenterprises
 
Suppose you like to keep a jar of change on your desk- Currently- the.pdf
Suppose you like to keep a jar of change on your desk- Currently- the.pdfSuppose you like to keep a jar of change on your desk- Currently- the.pdf
Suppose you like to keep a jar of change on your desk- Currently- the.pdfaarnnaenterprises
 
Select all the true statements concerning mitosis- Check All That Appl.pdf
Select all the true statements concerning mitosis- Check All That Appl.pdfSelect all the true statements concerning mitosis- Check All That Appl.pdf
Select all the true statements concerning mitosis- Check All That Appl.pdfaarnnaenterprises
 
So a few years ago- beef started between popeyes and chick fil a- Meme.pdf
So a few years ago- beef started between popeyes and chick fil a- Meme.pdfSo a few years ago- beef started between popeyes and chick fil a- Meme.pdf
So a few years ago- beef started between popeyes and chick fil a- Meme.pdfaarnnaenterprises
 
Questions for your consideration- - In what sense are museums public g.pdf
Questions for your consideration- - In what sense are museums public g.pdfQuestions for your consideration- - In what sense are museums public g.pdf
Questions for your consideration- - In what sense are museums public g.pdfaarnnaenterprises
 
On January 1- 2020- Blossom Corporation had 106-000 shares of no-par c.pdf
On January 1- 2020- Blossom Corporation had 106-000 shares of no-par c.pdfOn January 1- 2020- Blossom Corporation had 106-000 shares of no-par c.pdf
On January 1- 2020- Blossom Corporation had 106-000 shares of no-par c.pdfaarnnaenterprises
 
Mike can obtain specific performance of which contract- (A) Seller con.pdf
Mike can obtain specific performance of which contract- (A) Seller con.pdfMike can obtain specific performance of which contract- (A) Seller con.pdf
Mike can obtain specific performance of which contract- (A) Seller con.pdfaarnnaenterprises
 
Lana age 53 separated from service with her former employer in 2022 -s.pdf
Lana age 53 separated from service with her former employer in 2022 -s.pdfLana age 53 separated from service with her former employer in 2022 -s.pdf
Lana age 53 separated from service with her former employer in 2022 -s.pdfaarnnaenterprises
 
Joe and Kiran work the same or very similar jobs within the same compa.pdf
Joe and Kiran work the same or very similar jobs within the same compa.pdfJoe and Kiran work the same or very similar jobs within the same compa.pdf
Joe and Kiran work the same or very similar jobs within the same compa.pdfaarnnaenterprises
 
If X has a binomial distribution with n-4 and p-0-3- then P(X-1)-.pdf
If X has a binomial distribution with n-4 and p-0-3- then P(X-1)-.pdfIf X has a binomial distribution with n-4 and p-0-3- then P(X-1)-.pdf
If X has a binomial distribution with n-4 and p-0-3- then P(X-1)-.pdfaarnnaenterprises
 
In preliminary results from couples using the Gender Choice method of.pdf
In preliminary results from couples using the Gender Choice method of.pdfIn preliminary results from couples using the Gender Choice method of.pdf
In preliminary results from couples using the Gender Choice method of.pdfaarnnaenterprises
 
If scientists could bore through Earth's interior- what change would t.pdf
If scientists could bore through Earth's interior- what change would t.pdfIf scientists could bore through Earth's interior- what change would t.pdf
If scientists could bore through Earth's interior- what change would t.pdfaarnnaenterprises
 
I need help answering this question f- Calculate the average number o.pdf
I need help answering this question  f- Calculate the average number o.pdfI need help answering this question  f- Calculate the average number o.pdf
I need help answering this question f- Calculate the average number o.pdfaarnnaenterprises
 
Find a current event article based on the medical field that you would.pdf
Find a current event article based on the medical field that you would.pdfFind a current event article based on the medical field that you would.pdf
Find a current event article based on the medical field that you would.pdfaarnnaenterprises
 

More from aarnnaenterprises (20)

Write a brief research report (up to about 7 pages- not including titl.pdf
Write a brief research report (up to about 7 pages- not including titl.pdfWrite a brief research report (up to about 7 pages- not including titl.pdf
Write a brief research report (up to about 7 pages- not including titl.pdf
 
Q28- NADH and NADPH are activated electron carrier molecules that func.pdf
Q28- NADH and NADPH are activated electron carrier molecules that func.pdfQ28- NADH and NADPH are activated electron carrier molecules that func.pdf
Q28- NADH and NADPH are activated electron carrier molecules that func.pdf
 
Which of the following is NOT true about cholera- Caused by a virulent.pdf
Which of the following is NOT true about cholera- Caused by a virulent.pdfWhich of the following is NOT true about cholera- Caused by a virulent.pdf
Which of the following is NOT true about cholera- Caused by a virulent.pdf
 
Which is not true of Chile's economic development model- The main driv.pdf
Which is not true of Chile's economic development model- The main driv.pdfWhich is not true of Chile's economic development model- The main driv.pdf
Which is not true of Chile's economic development model- The main driv.pdf
 
Virus- Genome Classification- Describe (or draw) the path your virus t.pdf
Virus- Genome Classification- Describe (or draw) the path your virus t.pdfVirus- Genome Classification- Describe (or draw) the path your virus t.pdf
Virus- Genome Classification- Describe (or draw) the path your virus t.pdf
 
The probabily that a pecton thas a cerian divoase is 002 Medical diagn.pdf
The probabily that a pecton thas a cerian divoase is 002 Medical diagn.pdfThe probabily that a pecton thas a cerian divoase is 002 Medical diagn.pdf
The probabily that a pecton thas a cerian divoase is 002 Medical diagn.pdf
 
Suppose you like to keep a jar of change on your desk- Currently- the.pdf
Suppose you like to keep a jar of change on your desk- Currently- the.pdfSuppose you like to keep a jar of change on your desk- Currently- the.pdf
Suppose you like to keep a jar of change on your desk- Currently- the.pdf
 
Select all the true statements concerning mitosis- Check All That Appl.pdf
Select all the true statements concerning mitosis- Check All That Appl.pdfSelect all the true statements concerning mitosis- Check All That Appl.pdf
Select all the true statements concerning mitosis- Check All That Appl.pdf
 
So a few years ago- beef started between popeyes and chick fil a- Meme.pdf
So a few years ago- beef started between popeyes and chick fil a- Meme.pdfSo a few years ago- beef started between popeyes and chick fil a- Meme.pdf
So a few years ago- beef started between popeyes and chick fil a- Meme.pdf
 
Questions for your consideration- - In what sense are museums public g.pdf
Questions for your consideration- - In what sense are museums public g.pdfQuestions for your consideration- - In what sense are museums public g.pdf
Questions for your consideration- - In what sense are museums public g.pdf
 
On January 1- 2020- Blossom Corporation had 106-000 shares of no-par c.pdf
On January 1- 2020- Blossom Corporation had 106-000 shares of no-par c.pdfOn January 1- 2020- Blossom Corporation had 106-000 shares of no-par c.pdf
On January 1- 2020- Blossom Corporation had 106-000 shares of no-par c.pdf
 
P(A)-$5 and P(B)-45.pdf
P(A)-$5 and P(B)-45.pdfP(A)-$5 and P(B)-45.pdf
P(A)-$5 and P(B)-45.pdf
 
Mike can obtain specific performance of which contract- (A) Seller con.pdf
Mike can obtain specific performance of which contract- (A) Seller con.pdfMike can obtain specific performance of which contract- (A) Seller con.pdf
Mike can obtain specific performance of which contract- (A) Seller con.pdf
 
Lana age 53 separated from service with her former employer in 2022 -s.pdf
Lana age 53 separated from service with her former employer in 2022 -s.pdfLana age 53 separated from service with her former employer in 2022 -s.pdf
Lana age 53 separated from service with her former employer in 2022 -s.pdf
 
Joe and Kiran work the same or very similar jobs within the same compa.pdf
Joe and Kiran work the same or very similar jobs within the same compa.pdfJoe and Kiran work the same or very similar jobs within the same compa.pdf
Joe and Kiran work the same or very similar jobs within the same compa.pdf
 
If X has a binomial distribution with n-4 and p-0-3- then P(X-1)-.pdf
If X has a binomial distribution with n-4 and p-0-3- then P(X-1)-.pdfIf X has a binomial distribution with n-4 and p-0-3- then P(X-1)-.pdf
If X has a binomial distribution with n-4 and p-0-3- then P(X-1)-.pdf
 
In preliminary results from couples using the Gender Choice method of.pdf
In preliminary results from couples using the Gender Choice method of.pdfIn preliminary results from couples using the Gender Choice method of.pdf
In preliminary results from couples using the Gender Choice method of.pdf
 
If scientists could bore through Earth's interior- what change would t.pdf
If scientists could bore through Earth's interior- what change would t.pdfIf scientists could bore through Earth's interior- what change would t.pdf
If scientists could bore through Earth's interior- what change would t.pdf
 
I need help answering this question f- Calculate the average number o.pdf
I need help answering this question  f- Calculate the average number o.pdfI need help answering this question  f- Calculate the average number o.pdf
I need help answering this question f- Calculate the average number o.pdf
 
Find a current event article based on the medical field that you would.pdf
Find a current event article based on the medical field that you would.pdfFind a current event article based on the medical field that you would.pdf
Find a current event article based on the medical field that you would.pdf
 

Recently uploaded

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Recently uploaded (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Please help me fix the following errors in red- I attached the code be.pdf

  • 1. Please help me fix the following errors in red. I attached the code below for each file that contains an error. I did not attach the SortUtil.h file because it did not contain any errors. SortProfiler.cpp: #include <iostream> #include <cstdlib> #include <chrono> #include <iomanip> #include "arrayutil.cpp" #include "SortUtil.cpp" using namespace std; using namespace std::chrono; int main(int argc, char **argv) { int *iArray1, *iArray2, *iArray3; double *dArray1, *dArray2, *dArray3; long bTime, sTime, qTime; int size[] = {100, 500, 1000, 5000, 10000, 50000, 100000}; srand(time(NULL)); double *testArray = new double [50]; cout<<"***Testing Selection Sort***"<<endl; cout<<"Original Array:"<<endl; ArrayUtil::genRandArray(testArray,50); ArrayUtil::printArray(testArray,0,49,5); cout<<endl; SortUtil::selectionSortDouble(testArray,50); cout<<"Sorted Array:"<<endl; ArrayUtil::printArray(testArray,0,49,5); cout<<endl; cout<<"***Testing Bubble Sort***"<<endl; cout<<"Original Array:"<<endl; ArrayUtil::genRandArray(testArray,50); ArrayUtil::printArray(testArray,0,49,5); cout<<endl; SortUtil::bubbleSortDouble(testArray,50); cout<<"Sorted Array:"<<endl; ArrayUtil::printArray(testArray,0,49,5); cout<<endl; cout<<"***Testing Quick Sort***"<<endl; cout<<"Original Array:"<<endl; ArrayUtil::genRandArray(testArray,50);
  • 2. ArrayUtil::printArray(testArray,0,49,5); cout<<endl; SortUtil::quickSortDouble(testArray,0,49); cout<<"Sorted Array:"<<endl; ArrayUtil::printArray(testArray,0,49,5); cout<<endl; cout<<"Using Arrays with Random Doubles"<<endl; cout<<setw(8)<<left<<"n"<<setw(16)<<left<<"selectionSort"<<setw(16)<<left<<"bubbleSort"< <setw(12)<<left<<"quickSort"<<endl; for(int i = 0; i < 50; i++) cout<<"-"; cout<<endl; for (int i = 0; i < 7; i++) { dArray1 = new double[size[i]]; dArray2 = new double[size[i]]; dArray3 = new double[size[i]]; ArrayUtil::genRandArray(dArray1,size[i]); ArrayUtil::arrayCopyDouble(dArray1, 0, dArray2, 0, size[i]); ArrayUtil::arrayCopyDouble(dArray1, 0, dArray3, 0, size[i]); auto start = high_resolution_clock::now(); SortUtil::selectionSort(dArray1,size[i]); auto elapsed = high_resolution_clock::now() - start; sTime = duration_cast<microseconds>(elapsed).count(); start = high_resolution_clock::now(); SortUtil::bubbleSort(dArray2,size[i]); elapsed = high_resolution_clock::now() - start; bTime = duration_cast<microseconds>(elapsed).count(); start = high_resolution_clock::now(); SortUtil::quickSort(dArray3,0,size[i]-1); elapsed = high_resolution_clock::now() - start; qTime = duration_cast<microseconds>(elapsed).count(); cout<<setw(8)<<size[i]<<setw(16)<<sTime<<setw(16)<<bTime<<setw(12)<<qTime<<endl; delete[] dArray1; delete[] dArray2; delete[] dArray3; } cout<<endl<<endl; return 0; } SortUtil.cpp: #include <iostream>
  • 3. #include <algorithm> #include "SortUtil.h" using namespace std; static void arrayCopy (int source[], int sourceStart, int dest[], int destStart, int size) { for (int i = 0 ; i < size; i++) { dest [destStart + i] = source [sourceStart + i]; } } static int partition(int data[], int start, int end) { //implement this function return 0; } static void merge(int data[], int first[],int sizeFirst, int second[], int sizeSecond) { int iFirst = 0; int iSecond = 0; int j = 0; while (iFirst < sizeFirst && iSecond < sizeSecond) { if (first[iFirst] < second[iSecond]) { data[j] = first[iFirst]; iFirst++; } else { data[j] = second[iSecond]; iSecond++; } j++; } arrayCopy(first, iFirst, data, j, sizeFirst-iFirst); arrayCopy(second, iSecond, data, j, sizeSecond-iSecond); } /* sorting functions */ void SortUtil::bubbleSort(int data[], int size) { //implement this function } void SortUtil::selectionSort(int data[], int size) { //implement this function }
  • 4. void SortUtil::insertionSort(int data[],int size) { for (int i = 1; i < size; i++) { int next = data[i]; int j = i; while (j > 0 && data[j-1] > next) { data[j] = data[j-1]; j--; } data[j] = next; } } void SortUtil::quickSort(int data[], int start, int end) { //implement this function } void SortUtil::mergeSort(int data[], int size) { if (size <= 1) return; int *first = new int[size/2]; int *second = new int[size -size/2]; arrayCopy(data,0,first,0,size/2); arrayCopy(data,size/2,second,0,size-size/2); mergeSort(first,size/2); mergeSort(second,size-size/2); merge(data, first,size/2, second, size-size/2); delete[] first; delete[] second; } arrayutil.cpp #include <cstdlib> #include<iostream> #include<iomanip> #include <cstring> #include <climits> #include "arrayutil.h" using namespace std; template <typename T> void ArrayUtil::arrayCopy(T a[], int i, T b[],int j, int numElems) {
  • 5. /* for (int m = i; m < (i+numElems); m++) { b[j] = a[m]; j++; } */ memcpy(&b[j],&a[i],sizeof(T)*numElems); } template <typename T> void ArrayUtil::genRandArray(T* data, int size) { srand(time(NULL)); T factor = 1; for (int i=0; i<size;i++) data[i]=rand()%INT_MAX*factor; } template <typename T> void ArrayUtil::genSortedArray(T* data, int size, bool ascending) { int i; T factor = 1; if (ascending) { for (i=0; i<size;i++) data[i] = i*factor; } else { for (i=0; i<size;i++) data[i]=size-i*factor; } } template <typename T> void ArrayUtil::printArray(T data[],int first,int last, int numPerLine) { for (int i = first; i <= last; i++) { cout<<fixed<<setprecision(4); cout<<setw(10)<<data[i]<<" "; if ((i - first + 1) % numPerLine == 0) cout<<endl; } }
  • 6. arrayutil.h #include <cstdlib> #include <iostream> #ifndef ARRAYUTIL_H #define ARRAYUTIL_H using namespace std; namespace ArrayUtil { /** copies numElems elements from array a to array b * starting at position i in array a and starting at * position j in array b. * @param a - the source array * @param i - the starting index in the source array * @param b - the destination array * @param j - the starting index in the destination array * @param numElems - the number of elements to copy from * the source array into the destination array. */ template <typename T> void arrayCopy (T a[], int i, T b[], int j, int numElems); /** * This function fills an array with random numbers * @param data - array * @param size - size of the array */ template <typename T> void genRandArray (T* data, int size); /** * This function fills an array with numbers in ascending or descending order * @param data - array * @param size - size of the array */ template <typename T> void genSortedArray (T *data, int size, bool ascending); /** * Prints elements whose subscripts are in the range F to L * of an array, numPerLine elements per line. * @param data - an array containing data to be printed. * @param first the first index of the array. * @param last the last index of the array. */ template <typename T> void printArray (T data[], int first, int last, int numPerLine);
  • 7. } #endif GDB online Debugger | Compiler - Code, Compile, Run, Debug online C, C++ C Post a new question 4 Compilation failed due to following error(s).