Question: Your job is to finish writing one function: topThree, in potd.cpp. This function takes in the name of a file, reads the entries of a

Your job is to finish writing one function: topThree, in potd.cpp. This function takes in the name of a file, reads the entries of a file, and returns a vector containing the top three most occurring entries (in order from most frequent to least frequent in indicies 0 through 2). The file will always contain strings, and each string will have a unique frequency (i.e., you don't have to worry about breaking ties). Additionally, each of our input files will have at least 3 unique entries.

#include

#include

#include

#include

#include

using namespace std;

vector topThree(string filename) {

string line;

ifstream infile (filename);

vector ret;

if (infile.is_open()) {

while (getline(infile, line)) {

// do things

}

}

infile.close();

return ret;

}

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 Databases Questions!