Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Language. First question is for context, need help with 2). All functions should be in one main.cpp 1) A function is needed to

In C++ Language.

First question is for context, need help with2).All functions should be in one main.cpp

1)A function is needed to generate 10 unique dataset files of unsorted integers separated by a comma ",". E.g., 34, 32421, 124124, 67, 92, ... The sizes of these 10 datasets are (n) - 1000, 4000, 8000, 10000, 40000, 80000, 100000, 400000, 800000, 1000000. Generate random integers between 0 to 1,000,000 as the elements of each dataset. This function does not take any input arguments. This function generates and saves 10 ".txt" files. The output of this function is just a print statement to console that file generation completed.

#include

#include

#include

#include

using namespace std;

//main method

int main(){

srand(time(0));

int sizes[] = {1000, 4000, 8000, 10000, 40000, 80000, 100000, 400000, 800000, 1000000};

for(int i=0;i<10;i++){

ostringstream ss;

ss << i;

string ch = ss.str();

string filename = "filename"+ch+".txt";

fstream file;

//opening the file

file.open(filename.c_str(),ios::out);

for(int j=0;j //writing to the file separating by commas

if(j!=sizes[i]-1){

file< }else{

file< }

}

//closing this file

file.close();

}

cout<<"Files written"< return 0;

}

2) A function is needed to read the data from the above-generated files and construct 10 unsorted arrays. This function does not take any input arguments. This function declares 10 arrays of sizes sufficient to store the content of the above-generated files and constructs these arrays by reading these files. The output of this function is just a print statement to console that unsorted array generation completed.

Please help, thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions