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
UkoKoshka [18]
3 years ago
7

Two character strings may have many common substrings. Substrings are required to be contiguous in the original string. For exam

ple, photograph and tomography have several common substrings of length one (i.e., single letters), and common substrings ph, to, and ograph as well as all the substrings of ograph. The maximum common substring length is 6. Let X = X122 . Im and Y = yıy2 - - • Yn be two character strings. Using dynamic programming, design an algorithm to find the maximum common substring length for X and Y using dynamic programming. Please follow the general steps for designing a dynamic programming solution as in Q1 (other than the actual programming part).
Computers and Technology
1 answer:
ryzh [129]3 years ago
8 0

Answer:

Explanation:

The following function is written in Java. It takes two strings as parameters and calculates the longest substring between both of them and returns that substring length.

import java.util.*;

class Test

{

   public static void main(String[] args)

   {

       String X = "photograph";

       String Y = "tomography";

       System.out.println(X + '\n' + Y);

       System.out.println("Longest common substring length: " + longestSub(X, Y));

   }

   static int longestSub(String X, String Y)

   {

       char[] word1 = X.toCharArray();

       char[] word2 = Y.toCharArray();

       

       int length1 = X.length();

       int length2 = Y.length();

       int substringArray[][] = new int[length1 + 1][length2 + 1];

       int longestSubstringLength = 0;

       

       for (int i = 0; i <= length1; i++)

       {

           for (int j = 0; j <= length2; j++)

           {

               if (i == 0 || j == 0)

                   substringArray[i][j] = 0;

               else if (word1[i - 1] == word2[j - 1])

               {

                   substringArray[i][j]

                           = substringArray[i - 1][j - 1] + 1;

                   longestSubstringLength = Integer.max(longestSubstringLength,

                           substringArray[i][j]);

               }

               else

                   substringArray[i][j] = 0;

           }

       }

       return longestSubstringLength;

   }

}

You might be interested in
When entering numbers that start with a zero, apply the _____ number format.
yuradex [85]

Answer:

The Answer is gonna be D. Zero decimal

3 0
2 years ago
Protocol 2 - Check for Errors
Lapatulllka [165]

Please note that the Problem to be solved from Protocol 1 is not provided hence the general answers. To construct and send, open a network environment a single multi-packet message, simply click "Add Packet" and then click "Send at Once".

<h3>How will the receiver know the order of the packets or if any are missing?</h3>

If the text or message sent does not make any reading sense, or if certain words are jumbled and out of place, then it is clear that something is wrong.

If the messages arrive in a coherent fashion, then the packet was fully received.

<h3>How will the receiver request missed packets and what will the sender do in response?</h3>

Where the users are familiar with the Transmission Control Protocol, lost packets can be detected when there is a timeout. Lost packets are referred to as Dropped packets.

Learn more about Packets at:
brainly.com/question/17777733

7 0
1 year ago
Which management function do leaders perform first when an organization begins a project?
riadik2000 [5.3K]

Answer:

PLANING

Explanation:

They include: planning, organizing, leading, and controlling. You should think about the four functions as a process, where each step builds on the others. Managers must first plan, then organize according to that plan, lead others to work towards the plan, and finally evaluate the effectiveness of the plan.

6 0
3 years ago
Melanie needs to ensure that readers are able to locate specific sections within a document easily. What should she include in t
kozerog [31]

Answer:

in this case is table of contents

Explanation:

If Melanie want to organize the content, she can use index or table of content, but for specific sections table of content is easier to use.

For example:

Melanie can organize the titles in different levels like subtitle at the same page.

1 History..................................1

1.2 USA History....................1

 1.3 California History..........1

Melanie have to mark every title and subtitle in the document like "History -title 1", "USA History - title 2", "California History - title 3".

Melanie can create the table on content automatically in Word: at the section -> Reference -> table of content.

Readers can locate every important section by page, title and subtitle.

5 0
3 years ago
Read 2 more answers
Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print
snow_tiger [21]

Answer:

Step by step explanation along with C++ code is provided below.  

C++ Code:

#include <iostream>

using namespace std;

int main()

{

int numRows;

int numCols;

int r = 1;

cout <<"Please enter no. of rows"<<endl;

cin>>numRows;

cout <<"Please enter no. of columns"<<endl;

cin>>numCols;

cout<<"Seating arrangement in the theater:"<<endl;

for(int i = 0; i < numRows; i++)

{

  char c = 'A';  

 for(int j = 0; j < numCols; j++)

 {

  cout <<r << c << " ";

  c= c + 1;

 }

 r= r + 1;

}

  return 0;

}

Explanation:

// the outer loop prints the rows

// counter r = r + 1 increments the rows

// the inner loop prints columns

// counter c = c + 1 increments the columns

//  int r = 1 ensures that rows starts from 1

Output:

The program is tested multiple times and is working correctly for any number of rows and columns

Please enter no. of rows

2

Please enter no. of columns

3

Seating arrangement in the theater:

1A 1B 1C 2A 2B 2C

5 0
3 years ago
Other questions:
  • Is Apple a consumer or luxury brand? Give examples.
    10·1 answer
  • What are the three major functions of a game engine?
    15·1 answer
  • "the magical number seven, plus or minus two" refers to the storage capacity of ________ memory.
    5·2 answers
  • I stole you pokemon cards :o
    6·2 answers
  • How is primary storage different from secondary storage? Select the TWO correct statements.
    12·1 answer
  • In java please
    13·1 answer
  • Use the drop-down menus to complete the statements about using column breaks in word 2016
    6·2 answers
  • Choose all that apply.
    5·2 answers
  • I will mark you as brainlist
    10·2 answers
  • Complete the following sentence.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!