Question: Given : // A helper class that stores // a word and a frequency. class Entry { public: string s; // Words to be stored

Given :

// A helper class that stores

// a word and a frequency.

class Entry

{

public:

string s; // Words to be stored

long long int freq; // frequencies

};

Use the given function below to store all words that start with the given string x. The word can be as a simple as the letter "a" or even go several characters long, store all instances in a vector using recursion. The words come with frequencies as to how many times the word has been used, this funciton is called from another function that sorts the words according to their frequencies. However, my problem lies within the function below, how can I store the words that start with string x in the vector, please help!

// Fills a vector with the strings that start with x in

// the tree with the given root.

// Must run in O(log(n) + k*log(k)) time.

void completions_recurse(string x, Node* root, vector &E)

{

}

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!