Question: An American spy is deep undercover in the hostile country of Phonemia. In order not to waste scarce resources, any time he wants to send
An American spy is deep undercover in the hostile country of Phonemia. In order not to waste scarce resources, any time he wants to send a message back home, he removes all the punctuation from his message and converts all the letters to uppercase. So, for example, to send the message,
“Abort the plan! Meet at the Dark Cabin.”
he would transmit
ABORTTHEPLANMEETATTHEDARKCABIN
Given such a string, S, of n uppercase letters, describe an efficient way of breaking it into a sequence of valid English words. You may assume that you have a function, valid(s), which can take a character string, s, and return true if and only if s is a valid English word. What is the running time of your algorithm, assuming each call to the function, valid, runs in O(1) time?
Step by Step Solution
3.32 Rating (158 Votes )
There are 3 Steps involved in it
Define Dj to be true if and only if the first i characters of S can be d... View full answer
Get step-by-step solutions from verified subject matter experts
