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]
3 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]3 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
If the VLOOKUP function is used to find an approximate match, what will it return if there is no exact match?
grigory [225]

Answer:

Its C

Explanation:

The largest value that is less then the lookup value

6 0
3 years ago
A__________is a system that incorporates all the technologies and applications found in a typical information system to gather,
Allisa [31]

Answer:

global information system (GIS)

Explanation:

A global information system (GIS) is an information system that works across national borders, facilitates communication between headquarters and subsidiaries in other countries, and incorporates all the technologies and applications found in a typical information system to gather, store, manipulate, and transmit data ...

6 0
3 years ago
Question 5 (2 points)
Scrat [10]

Answer:

B) 5 m/s

Explanation:

Took the test and this was the correct answer :)

6 0
3 years ago
Write an application for Cody’s Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery
Firdavs [7]

An application for Cody’s Car Care:

#include <iostream>

#include <string>

#include <vector>

using namespace std;

int main()

{

vector<string>stroptions(4);

stroptions[0] = "Oil Change";

stroptions[1] = "Tire Rotation";

stroptions[2] = "Battery Check";

stroptions[3] = "Brake Inspection";

 

vector<int> intprices(4);

intprices[0] = 45;

intprices[1] = 22;

intprices[2] = 15;

intprices[3] = 10;

 

int option;

cout<< "Welcome to Joe's Car Care Shop!" <<endl;

cout<< "Choose a service from our menu:" <<endl;

for(int i = 1; i<= 4; i++)

{

  cout<< "#" <<i<< ": " <<stroptions[i-1] <<endl;

}

cout<< "Choice: ";

bool loop = true;

while(loop)

{

  loop = false;

  cin>> option;

 switch(option)

  {

   case 1:

     cout<< "\nA " <<stroptions[option-1] << " will be: $" <<intprices[option -1] <<endl;

     break;

   case 2:  

     cout<< "\nA " <<stroptions[option -1] << " will be: $" <<intprices[option -1] <<endl;

     break;

   case 3:

     cout<< "\nA " <<stroptions[option -1] << " will be: $" <<intprices[option -1] <<endl;

     break;

   case 4:

     cout<< "\nA " <<stroptions[option -1] <<" will be: $" << intprices[option -1] <<endl;

      break;

    default:

     cout<< "\nYou entered an invalid item! Try again!" <<endl;

     loop = true;

     break;

 }

}

}

3 0
3 years ago
Laura is confused with the spelling of the word pronunciation. She types the word as pronounciation. Which feature of the Autoco
alexgriva [62]
The answer could be A..... replace
3 0
3 years ago
Read 2 more answers
Other questions:
  • The ________ of the operating system enables users to communicate with the computer system. modem window network adapter card us
    14·1 answer
  • What is the shortcut key to launch the Macros dialog box?
    14·1 answer
  • A style manual can be described as
    11·2 answers
  • Write a program that displays the following menu:
    8·1 answer
  • Write a program to draw a text-based graph of a mathematical function f(x)
    13·1 answer
  • Write the include directive needed to allow use of the various i/o functions and values such fprintf and fgetc.
    12·1 answer
  • if anyone is on a Chromebook, do you ever mean to press backspace, then you accidentally press the power button and think "OH CR
    13·2 answers
  • Blockquote
    11·1 answer
  • Tools used to build a bridge<br>​
    15·1 answer
  • 5.8.1 Ghosts Python Codehs
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!