1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
miskamm [114]
3 years ago
8

Given a non-empty string s and a dictionary containing a list of unique words, design a dynamic programming algorithm to determi

ne if s can be segmented into a space-separated sequence of one or more dictionary words. if s="algorithmdesign" and your dictionary contains "algorithm" and "design". your algorithm should answer yes as s can be segmented as "algorithmdesign

English
1 answer:
nlexa [21]3 years ago
8 0
Let s(i),k denote the substring s(i)s(i+1)...s k. Let Opt(k) denote whether the sub-string s1,k can be segmented using the words in the dictionary, namely (k) =1 if the segmentation is possible and 0 otherwise. A segmentation of this sub-string s1,k is possible if only the last word (say si  k) is in the dictionary theremaining substring s1,i can be segmented. 
Therefore, we have equation:Opt(k) =                    max                       Opt(i)          0<i<k and s(i+1),kis a word in the dictionary
We can begin solving the above recurrence with the initial condition that Opt(0) =1 and then go on to comput eOpt(k) for k= 1, 2. The answer correspond-ing to Opt(n) is the solution and can be computed in Θ(n2) time.

You might be interested in
Whats the adverb in the phrase <br> "The highway extends far across the state
Dmitrij [34]
Highway is the adverb
8 0
3 years ago
Read 2 more answers
What did the dirt say to the rain
Murljashka [212]
Nothing cuz dirt dont talk chile
8 0
3 years ago
The preschool teacher was shocked that a four your old child drew such an exquisite picture of a sunset. How does the phrase "of
konstantin123 [22]

It is a object of preposition!~

6 0
3 years ago
“Atticus was right. One time he said you never really know a man until you stand in his shoes and walk around in them. Just stan
horsena [70]

Answer: This passage from Chapter 31 is Scout's exercise in thinking about the world from Boo Radley's perspective.

6 0
3 years ago
Identify/write the adverbs in the following sentences.
iogann1982 [59]

A) new

B) there

C) without

D) rarely

8 0
4 years ago
Other questions:
  • A full-wave bridge rectifier uses how many diodes? A. One B. Two C. Three D. Four
    12·2 answers
  • Read the excerpt below and answer the question. After I had the piano tuned, I opened the lid and touched the keys. It sounded e
    12·2 answers
  • Writing an essay on my skill sets
    8·1 answer
  • Which of the following is the best definition for the prefix ex-?
    13·2 answers
  • Which statement is true?
    9·2 answers
  • 1.Whom did Frankenstein meet after he had ascended to the summit of Montanvert?
    9·2 answers
  • What is the topic sentence? "Most of the slaves in eighteenth-century Virginia were the children and grandchildren of people kid
    6·1 answer
  • Many students hope to have their own cars one day but young people are
    13·1 answer
  • Select the correct answer.
    14·2 answers
  • Which two words are the closest synonyms?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!