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
In Mandatory Military Service in America, with which of the following would the
mamaluj [8]

Answer:

The right answer is B. Forced conscription made many men go to Vietnam.They fought and after suffering all kinds of problems, ethical and physical, they were rejected as if they did not  to the nation that  had sent them to fight that war. American Citizsnship being weakened is well described by what the Veterans had to face on their return from the war.

Explanation:

6 0
3 years ago
Read 2 more answers
WHAT IS THE ANSWEEEER TO THIS ITS ON COMMMMMONLITT SOMEONEEEE PLEASEEEEE TELLLLLL MEEEE AND I WILLLLL BUYYYY YOU SOME COOKIES AN
Dmitrij [34]

Answer:

The attitude of the main character becomes careless.

Explanation:

As said in the 2nd paragraph, "I don't really care about my surgeries."

Hope this helps Mark Brainliest!

5 0
3 years ago
Identify ALL verbs in the sentence below:<br> This book has everything!
Leya [2.2K]

Answer:

has

Explanation:

5 0
1 year ago
Read 2 more answers
IN THE BOOK, BRIAN'S WINTER - Will Brian have luck with his new bow and arrows?
zaharov [31]

Answer:

yeh

Explanation:

7 0
2 years ago
Read 2 more answers
Identify the correct sentence " Octavia, may I have some orange juice?" He asked
charle [14.2K]
What is the question that you are asking?
5 0
3 years ago
Other questions:
  • Choose the answer in which capitalization is used correctly.
    13·2 answers
  • A writer is revising the sentence below:
    10·1 answer
  • How should the capitalization be corrected in the closing
    5·1 answer
  • What does Homer tell us about the Phaeacians? Select all that apply.
    8·1 answer
  • Which of the following is not a sign of bias in a website?
    6·2 answers
  • Homer included a very funny, though dark, the situation in Ulysses’s interaction with Polyphemus the Cyclops. In no less than se
    7·1 answer
  • 1. If you took a class that focused on the study of the earth, what root word would you most likely see in the course name?
    8·1 answer
  • 5) Fill in the gaps with the right forms of verbs in the bracket. .5x8=4
    7·1 answer
  • What did you learn from George Orwell?​
    13·1 answer
  • What inference can you make about the Great Exhibition after<br> reading this part of the passage?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!