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
56- What is the term used when you press and hold the left mouse key and more the mouse
elena55 [62]

Answer:

i'd say it's dragging, but i'm not 100% sure

Explanation:

8 0
2 years ago
What is the binary number 0011 0011 multiplied by two?
Nimfa-mama [501]

Answer:

1100110

Explanation:

0011 0011 = 51

51 x 2 = 102

5 0
3 years ago
Selecting missing puppies 1 # Select the dogs where Age is greater than 2 2 greater_than_2 = mpr [mpr. Age &gt; 2] 3 print(great
anygoal [31]

Answer:

# the dog dataframe has been loaded as mpr

# select the dogs where Age is greater than 2

greater_than_2 = mpr [mpr. age > 2]

print(greater_than_2)

# select the dogs whose status is equal to 'still missing'

still_missing = mpr[mpr. status == 'Still Missing']

print(still_missing)

# select all dogs whose dog breed is not equal to Poodle

not_poodle = mpr [mpr.breed != 'Poodle']

print(not_poodle)

Explanation:

The pandas dataframe is a tabular data structure that holds data in rows and columns like a spreadsheet. It is used for statistical data analysis and visualization.

The three program statements above use python conditional statements and operators to retrieve rows matching a given value or condition.

4 0
2 years ago
3. The following code will not display the results expected by the programmer. Can
Elena L [17]

Answer:

ion k

Explanation:

7 0
3 years ago
for java ?(Business: check ISBN-13)ISBN-13 is a new standard for identifying books. It uses 13 digits d1d2d3d4d5d6d7d8d9d10d11d1
ludmilkaskok [199]

Answer:

In Java:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 String isbn;

 System.out.print("First 1:2 digits: ");

 isbn = input.nextLine();

 if(isbn.length()==12){

 int chksum = 0;

 for(int i = 0; i<12;i++){

     if((i+1)%2==0){      chksum+= 3 * Character.getNumericValue(isbn.charAt(i));          }

     else{          chksum+=Character.getNumericValue(isbn.charAt(i));          }  }

 chksum%=10;

 chksum=10-chksum;

 if(chksum==10){

 System.out.print("The ISBN-13 number is "+isbn+"0");}

 else{

 System.out.print("The ISBN-13 number is "+isbn+""+chksum);          }   }

 else{

     System.out.print("Invalid Input");

 }     }}

Explanation:

See attachment for explanation where comments are used to explain each line

Download txt
6 0
3 years ago
Other questions:
  • Which statement prints "hi" on the screen?
    5·2 answers
  • Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the
    7·1 answer
  • Certain medications can increase risk of obtaining a sunburn true or false
    12·1 answer
  • What is the purpose for adding images and graphics to a web page?
    5·1 answer
  • Claudia has a bachelors degree in computer information systems and she has learned to use some popular software testing tolls wh
    13·2 answers
  • Suppose 8 people want to communicate with each other using public key encryption. The communication between any pair of them is
    7·1 answer
  • What date of us can be used on a desktop computer
    12·1 answer
  • A web application is an example of:
    7·1 answer
  • What was revolutionary about Web 2.0?
    5·1 answer
  • The data source in the document which has the information common to all documents. True or false 
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!