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
Is a computer an input output or storage
Effectus [21]

Answer:

Explanation:

A computer is a machine that can be programmed to accept data (input), process it into useful information (output), and store it away (in a secondary storage device) for safekeeping or later reuse. The processing of input to output is directed by the software but performed by the hardware.

6 0
3 years ago
An example of cooler red is
BARSIC [14]

apple, stop sign, fire truck, stop light... ect

6 0
3 years ago
ANSWER ALL QUESTIONS CORRECTLY PLEASE AND YOU WILL GET A BRAINLIEST AND 10+ POINTS!!!! I WOULD REALLY APPRECIATE IT
miskamm [114]

Answer: uhm can u explain what ICT is so i can understand the questions pls when i whould gladly help :)

Explanation:

7 0
3 years ago
What can a human till do better and fater than any Machine Learning (ML) olution?
Gemiola [76]

Judge the quality of any given data can a human till do better and fater than any Machine Learning (ML).

<h3>What is Machine Learning (ML)?</h3>
  • Switch between fields of expertise. a thorough understanding of the facts' meaning. Check the veracity of any information that is provided.
  • According to some scientists, AI will replace jobs with a single output. A mental task may also be mechanized in the future if it can be finished by a person in less than a second.
  • Expressing empathy, making others feel good, taking care of others, expressing feelings and vulnerability in a sympathetic way, and making people laugh are all examples of being creative and artistic for the purpose of being creative. The personal touch is important in most occupations and, in certain cases, it completes the task entirely.
  • Machines can perform as well as or better than humans in some tasks, despite their slower rate of development.

To learn more about Machine Learning (ML) refert to:

brainly.com/question/25523571

#SPJ4

5 0
1 year ago
If a business industry does not meet OSHA standards
soldi70 [24.7K]

Explanation:

USE SOCRACTIC IT WOULD REALLY HELP

7 0
4 years ago
Read 2 more answers
Other questions:
  • Array testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cre
    10·1 answer
  • Laura is using studio lighting while photographing a model. The four elements that she will use in studio lighting are hot light
    10·1 answer
  • Which of the following best describes the protocols used on the Internet?
    9·1 answer
  • How to learn how to use computers
    9·1 answer
  • What happens when you get 3 warnings on this site?
    9·2 answers
  • What is the first step to apply the line and page breaks options to groups of paragraphs in a Word document?
    10·2 answers
  • Adios brainly, you were sh.t sometimes, but you had your moments, wont be posting that much take my points away i d c
    6·2 answers
  • assume there are K sorted lists, each of n/k elements. We want to merge them into a single sorted list of n elements. Give an op
    7·1 answer
  • Which of the following safety and privacy features is not included in a P2P app or service?
    5·2 answers
  • TensorFlow and Pytorch are examples of which type of machine learning platform?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!