Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions