Assume we are writing a tool which needs a word completion feature for English. We have a dictionary of all English words (comma-separated text file). The tool should show a maximum of three possible words if found at any time. - Provide pseudo code or full code. Q2. Describe and explain the time complexity of your search algorithm (Big-O) for the above problem. - Can we use this for real-time word-completion suggestions? i.e. suggest completion options as the user is typing.
Answers
Answer :
Given an input string and a dictionary of words, find out if the input string can be segmented into a space-separated sequence of dictionary words. See following examples for more details.
Consider the following dictionary
{ i, like, sam, sung, samsung, mobile, ice,
cream, icecream, man, go, mango}
Input: ilike
Output: Yes
The string can be segmented as "i like".
Input: ilikesamsung
Output: Yes
The string can be segmented as "i like samsung"
or "i like sam sung".
Answer:
Writing an algorithm is just like preparing plan to solve
the problem.
Algorithm just gives the solution but not the answer.
Importance of writing algorithms are:
We can save the resources like time, human effort & cost
Debugging will be easier.
Since they are written using pseudo code, any technical person
can understand easily
Can be used as an design document
Once algorithm is written & understood neatly, easily can be
converted into executable program by using any programming
language
#SPJ2