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]
2 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]2 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
What is theme of surah an-naba ? what dose surah draw attention to ?
VMariaS [17]

This Surah tells them that the Day of Decision is coming. Its theme is almost the same as that of Surah Mursalat. The first twenty verses narrate and depict the wonders of the worldly creation, and the last twenty verses are packed with the eternal wonders and horrors of the next world. The News (Arabic: النبأ‎, an-nabaʼ, aka "The Tidings", "The Announcement") is the seventy-eighth chapter (surah) of the Quran with forty verses (ayat).

8 0
3 years ago
When the speaker says he is "six miles from earth, lossed from its dream of," what does he mean?
Ierofanga [76]

the correct answer is C


7 0
3 years ago
What is the subject within the sentence below?
igomit [66]

The subject is "we".

5 0
3 years ago
In the sentence, “My friends and I looked around for our sleds.” is around a preposition or an adverb?
Allisa [31]

Answer:

It is a preposition.

Explanation:

A preposition is a word governing, and usually preceding, a noun or pronoun and expressing a relation to another word or element in the clause, as in “the man on the platform,” “she arrived after dinner,” “what did you do it for ?”

An adverb is a word or phrase that modifies or qualifies an adjective, verb, or other adverb or a word group, expressing a relation of place, time, circumstance, manner, cause, degree, etc. (e.g., gently, quite, then, there ).

Hope this helps  :  )

4 0
3 years ago
Read the sentence below and answer the following question:
olasank [31]
The answer would be incessant
5 0
2 years ago
Read 2 more answers
Other questions:
  • Which of these patterns do writers use to organize nonfiction texts? introduction, preface, and list of resources discussion, de
    7·2 answers
  • 89 POINTS IKR HIGH SCORE! NOT LYING! HELP MEEEEE! Which of these BEST describes England's situation on the eve of the Industrial
    14·2 answers
  • Decide whether each group of words is a clause or a phrase, and then sort each tile into the appropriate category.
    10·1 answer
  • 1. Why do we need to clean?<br><br>I believe________​
    12·1 answer
  • What are chery's greatest strengths in the book outsiders
    15·1 answer
  • How does the author develop Maggie and her mother’s relationship in the excerpt?
    5·1 answer
  • Change the form of the words and fill the gaps.
    11·1 answer
  • How does the war between Ukraine and Russia affect the world? Explain
    11·2 answers
  • Part A
    5·1 answer
  • CODE TALKER BOOK
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!