Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Now that we have the words stored, it is time to provide functions that allow users to use our dictionary. Add and implement the following
Now that we have the words stored, it is time to provide functions that allow users to use our dictionary. Add and implement the following functions:
/* @param : The string with a query word @return : Integer index of the word in `g_words` global-array. Returns -1 if the word is not found @post : Find the index of given `word` in the `g_words` array. Return -1 if word is not in the array */ int getIndex(string word); /* @param : The string with a query word @return : Return the string definition of the word from `g_definitions` global-array. Return "NOT_FOUND" if word doesn't exist in the dictionary @post : Find the definition of the given `word` Return "NOT_FOUND" otherwise */ string getDefinition(string word); /* @param : The string with a query word @return : Return the string part-of-speech(pos) from the `g_pos` global-array. Return "NOT_FOUND" if the word doesn't exist in the dictionary. @post : Find the pos of the given `word` Return "NOT_FOUND" otherwise */ string getPOS(string word); /* @param : The string prefix of a word (the prefix can be of any length) @return : Integer number of words found that starts with the given `prefix` @post : Count the words that start with the given `prefix` */ int countPrefix(string prefix);
Remember to test each function before moving on to implement the next one. Similar to Task A, submit only one .cpp file without the main() function
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