Question: Problem 2 : Choose a single existing data structure implementation * not including the list data structure implementations ( i . e . your options

Problem 2: Choose a single existing data structure implementation* not including the list data structure implementations (i.e. your options are, most likely, ArrayStack, CLQueue, BST, Heap) from class. You are to write a C++ program that will
i.(30 pts) read your dataset* from part 1 of the project (or you can choose a new one, if preferred) into your chosen structure, and
ii.(20 pts) print a subset of rows/records from your dataset in response to user input. I will be flexible with the latter, but the user must be able to provide an input value that changes what elements of your data are printed. Some ideas are below (you can use any of these, modify them, or come up with your own):
a. Print out elements of a BST with a chosen attribute/column that exceeds a certain value (ex: for the CCFraud data only rows with more than an input value for amount.)
b. Print out elements from a PQ heap matching the k highest or k lowest (where k is a value input by the user) values for a chosen attribute/column.
c. Print out every kth element loaded into a CLQueue (again, where k is a value input by the user)
Note: you will likely want to consult and/or modify the main.cpp file you used in part 1(or create one, if you did not finish!) to handle the reading of data into the structure, as well as writing of it. But remember you will also need to modify the new data structure you have chosen, which includes details such as modifying or removing other operations (ex: there is likely no need to keep DeleteItem for the BST, and you can potentially even discard the traversals and traversal queue if you like)
#include "ASListR.h"
#include
#include
#include
using namespace std;
ASListR csvtoASListR(string csvfile){//convert a csv file to a list structure
ASListR retCCList(205); //Make sure the array has sufficient size for our data
ifstream ReadFile(csvfile); //open the csv file for reading
string line, curvalue;
getline(ReadFile, line); //throw away the first line (column names)
while (getline(ReadFile,line)){
stringstream ss(line); //turn the line into a string-stream
int fielditer=0;
cpus newrec;
while(getline(ss, curvalue, ',')){//Separate each variable per sample from the comma separator
switch (fielditer){//We need to explicitly convert values to the appropriate type (stoi=integer, stod=double)
case 0: newrec.Process=stoi(curvalue); break;
case 1: newrec.Cores=stod(curvalue); break;
case 2: newrec.Codename=stoi(curvalue); break;
}
fielditer++;
}
retCCList.PutItem(newrec);
}
return retCCList;
}
int main(int argc, char** argv){
ASListR cpu=csvtoASListR("cpu.csv");
cpu.PrintList(); //Print the data to make sure they are correct order (in this case, in decreasing order by cost)
}.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!