Question: Using c++ Im given an Autocompleter task, where I must complete the functions in a file called autocompleter.cpp. One of the sections wants me to

Using c++ Im given an Autocompleter task, where I must complete the functions in a file called autocompleter.cpp. One of the sections wants me to fill a vector with 3 of the most frequent completions of a word that it must find using a completed BST filled with a class I called Entries (contains an int and string, for frequencies and word). How do I look for those in a BST and put them in the vector? I am allowed to use a helper function.

// Fills the vector T with the three most-frequent completions of x. // If x has less than three completions, // then T is filled with all completions of x.

// // Must run in O(log(n) + k) time, // where k is the number of completions of x in the dictionary. void completions(string x, vector &T); // The completions appear in T from most- to least-frequent. // // Must run in O(log(n) + k) time, // where k is the number of completions of x in the dictionary. void completions(string x, vector &T);

This is the helper function.

// Fills T with the three most-frequent completions of x // that are either: // -In the BST rooted at root. // -Already in T. // // Should run in O(log(n) + k), where // -n is the size of the BST rooted at root. // -k is the number of Entrys in the BST rooted at root // whose strings start with x. void completions_recurse(string x, Node* root, vector &T);

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!