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
Alex_Xolod [135]
4 years ago
12

You are given a string of n characters s[1 : : : n], which you believe to be a corrupted text document in which all punctuation

has vanished (so that it looks something like itwasthebestoftimes...). You wish to reconstruct the document using a dictionary, which is available in the form of a Boolean function dict(): for any string w, dict(w) = true if w is a valid word false otherwise . (a) Give a dynamic programming algorithm that determines whether the string s[] can be reconstituted as a sequence of valid words. The running time should be at most O(n2), assuming calls to dict take unit time. (b) In the event that the string is valid, make your algorithm output the corresponding sequence of words.
Computers and Technology
1 answer:
alexdok [17]4 years ago
8 0

Answer: provided in the explanation section

Explanation:

Given that:

Assume D(k) =║ true it is [1 : : : k] is valid sequence  words or false otherwise

  • To determine D(n)

now the sub problem s[1 : : : k] is a valid sequence of words IFF s[1 : : : 1] is a valid sequence of words and s[ 1 + 1 : : : k] is valid word.

So, from here we have that D(k) is given by the following recorance relation:

D(k) = ║ false maximum (d[l]∧DICT(s[1 + 1 : : : k]) otherwise

Algorithm:

Valid sentence (s,k)

D [1 : : : k]             ∦ array of boolean variable.

for a ← 1 to m

do ;

d(0) ← false

for b ← 0 to a - j

for b ← 0 to a - j

do;

if D[b] ∧ DICT s([b + 1 : : : a])

d (a) ← True

(b). Algorithm Output

      if D[k] = = True

stack = temp stack           ∦stack is used to print the strings in order

c = k

while C > 0

stack push (s [w(c)] : : : C] // w(p) is the position in s[1 : : : k] of the valid world at // position c

P = W (p) - 1

output stack

= 0 =

cheers i hope this helps !!!

You might be interested in
Which of the following statements is true?
jeka57 [31]

Answer: Constructors can specify parameters but not return types.

Explanation:

public class Student {

 int roll_no;

 public Student(int a) {

   roll_no = a;

 }

public static void main(String[] args) {

   Student abs = new Student(10);

   System.out.println(abc.roll_no);

 }

}

In the above code we have illustrated the working of constructors. We have a class with the name Student. then a constructor is created of the class called as the class constructor. In the main we create an object of the class and with this object we invoke the constructor and also pass a parameter. Here in the code we are passing the roll no of the student.

So we can say that constructor is called during the runtime when the object created invokes the constructor so a constructor can have many arguments but it does not have a return type.

7 0
3 years ago
Two support services supervisors disagree about a position description for a new help desk position. One said, “The position des
Reptile [31]

I aggree with the one that says "The position description should be as specific as we can make it so applicants will know whether or not they meet our requirements.”

Note that when the  specific requirements about a position is made known, it makes the applicant to known if they are fit for that position or not

<h3>What is a position description?</h3>

The term  position description is also known as "PD" . This is known to be a fact or a statement that talks about the key duties, responsibilities, and role etc. of a position.

It helps to indicates the work to be carried out by the position and when it is specific, one can know if they can do the work or not.

Learn more about position description from

brainly.com/question/4677114

4 0
3 years ago
When did edison invent the incandescent light bulb?
arlik [135]
Edison revealed his incandescent light bulb on December 31, 1879<span>, in Menlo Park, California.</span>
4 0
3 years ago
Read 2 more answers
Given a Scanner reference variable named input that has been associated with an input source consisting of a sequence of strings
Usimov [2.4K]

Answer:

// Program segment is written in Java programming language

// Comments are used for explanatory purpose

// Program segment starts here

// Initialise the two in variable to 0

count = 0;

longest =0;

// define the string variable

String myString = new String();

// Check if scanner reference contains string using while iteration

while (input.hasNext()){

// Input string while condition is true

myString = input.next();

// Compare length of string with longest variable

if (myString.length() == longest)

{

// If equal, increment count by 1

count++;

}

// If length of string is greater than longest

else

if (myString.length() > longest)

{

longest = myString.length(); // assign length of string to longest

count = 1; // set count to 1

}

}

// End of code segment

6 0
3 years ago
Read 2 more answers
What is the simplest way to convert a decimal number in a binar one in c++?
Fiesta28 [93]
It's easy you need to use function for decimal in binary.
binary STD;
int STD_no;
STD=STD_No.ToBinary

4 0
3 years ago
Other questions:
  • Convert 1001101012 to base 10
    5·1 answer
  • Define a void function that calculates the sum (+), difference (-), product (*), quotient (/), and modulus (%) of two integer nu
    14·1 answer
  • The process of using or controlling two or more windows at a time is known as. a threading .b multitasking. c hyperthreading.d s
    13·1 answer
  • You want to substitute one word with another throughout your document. What tool(s) should you use?
    9·1 answer
  • You wish to enter your exam scores in a spreadsheet. Which function will help you find how each subject’s score relates to the o
    15·2 answers
  • Pleases Help ME An example of a _________________ impact is when a product is back ordered and the business contacts the custome
    5·1 answer
  • Help Me<br><br> What are the four types of graphic models?
    10·1 answer
  • The Table Design and Layout tabs are available under the
    13·2 answers
  • How do you take a picture on an apple computers
    7·1 answer
  • Mr. stevens is the principal of a high school. why might he want to export data from a database of students’ exam scores? to cre
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!