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
A vast global network that is made up of many smaller interconnected networks is known as:
Galina-37 [17]

The answer is The Internet.   It is a vast global network that is made up of many smaller interconnected networks. It connects to millions of computer units world wide, in which any computer can communicate with any other computer as long as they are both connected to the Internet. It also made access to information and communication easier.

6 0
3 years ago
Read 2 more answers
Fill in the blanks Pasaline could ----- and ------- very easily.​
Artemon [7]

Answer:

<h2>Hot you too friend's house and be safe and have a great time to take care of the following is not a characteristic it was a circle whose equation o</h2>
6 0
3 years ago
In which scenario would you view Word data in Excel?
s344n2d4d5 [400]

A. You want to analyze data from a table within a report, with functions and chats.

6 0
3 years ago
What should a pie chart represent?
Crazy boy [7]

Answer:

Data that adds up to 100%

Explanation:

7 0
2 years ago
When you are using the internet to research a school project, and you ignore the banner ads on websites even though you see them
FinnZ [79.3K]

Answer:

The answer is "selective exposure".

Explanation:

It is a theory in psychology, that is sometimes used in marketing and advertising studies. It traditionally applies to the propensity of people to prefer evidence, that enhances existing previous views while ignoring conflicting information.

These types of approaches are occurring, when the people pursue knowledge and consistently express desires for solutions, that are associated with their beliefs, rather than incompatible.

5 0
3 years ago
Other questions:
  • The ____ keyword specifies that a function or method does not return a value.
    5·1 answer
  • I have a class named Counter. In this class I have a synchronized method called countRange(). This method prints out a count in
    10·1 answer
  • Your company has been using Windows workgroups on a server running Windows Server 2016. Due to the rapid growth of the company,
    9·1 answer
  • What is your favourite video game??​
    5·2 answers
  • A ? is the desired value where a process should be maintained. The value may be manually set, automatically set, or programmed.
    13·1 answer
  • What device is used to transmit what is effectively a type of Morse code between stations?
    11·1 answer
  • If you have a database of books in the library and you would like to find all books published after January 1, 2008, what criter
    7·1 answer
  • Computers are able to think like human beings true or false?
    10·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    7·2 answers
  • Swapping as applied in memory management with an aid of a diagram​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!