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
what option can be used to create vpn connections that can be distributed to users' computers so that vpn clients do not have to
IRINA_888 [86]

This option can be used to create virtual private network (VPN) connections that can be distributed to users' computers so that VPN clients do not need to be configured on each client station is a VPN connection profile.

Users can send and receive data over shared or public networks as if their computer equipment were physically connected to a private network using a virtual private network (VPN), which extends the private network over the public network.

Increased functionality, security, and private network administration are all benefits of a VPN. It is often used by remote workers and allows access to resources that are not available on the public network. Although not an essential part of a VPN connection, encryption is often used.

By using dedicated circuits or tunneling protocols over existing networks, a VPN can be created by creating a virtual point-to-point connection.

To know more about VPN click here:

brainly.com/question/28945467

#SPJ4

6 0
1 year ago
Select all of the uses of presentation software in the workplace.
zaharov [31]

Answer:

uhm 1, 2, 3, 4, 6, 7, and 8.

Explanation:

because those are all the uses of presentation software in a workplace.

8 0
4 years ago
This is a free point thing!! I am giving 100 points!! Anyone wanna talk!!!!
julia-pushkina [17]

Answer:

:)

Explanation:

8 0
3 years ago
Read 2 more answers
If I use the command right(90), which way will Tracy turn?<br> If correct I mark brainlist
Kaylis [27]

Answer: Right

Explanation: If you use the Command Right (90°), it makes sense that Tracy turns right 90°...

5 0
2 years ago
When a packet with the code is transmitted, it is received and processed by every machine on the network. this mode of operation
enot [183]
Multicast

------------------------------------
6 0
3 years ago
Other questions:
  • You are troubleshooting a network issue on a client computer and discover that the network card has an IP address of 169.254.196
    6·1 answer
  • How can i add card reader to pc answers?
    9·1 answer
  • Assume a 8x1 multiplexer’s data inputs have the following present values: i0=0, i1=0, i2=0, i3=0, i4=0, i5=1, i6=0, i7=0. What s
    8·1 answer
  • HTTP is made to facilitate which kind of communication?
    11·1 answer
  • _____ remove the part of an image starting from an edge​
    13·1 answer
  • VOTE!
    11·1 answer
  • Which option should you select to accept a tracked change? A. Accept B. Reject C. Review D. Delete
    8·2 answers
  • The most important hardware device for connecting supercomputers over a wide area
    10·1 answer
  • I connected to an external hard drive to transfer some photos from my vacation. When I try to drag the photo, it bounces right b
    14·1 answer
  • Assert statements are a tool programmers employ to help them debug their code more efficiently.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!