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
{
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started