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
1. Science is the body of knowledge and methods produced by engineering.
olga nikolaevna [1]
True. Technology changes society
6 0
3 years ago
Each webpage is assigned a(n) ______, an address that identifies the location of the page on the Internet.
timofeeve [1]

Answer:

The answer is "URL".

Explanation:

The term URL is also known as the "Uniform-Resource-Locator", which is also known as the address of the website or internet file. To access this file we use to type its address in the web browser by using the "http:// or https://" protocol. It contains the domain name, with several other basic data to guide a visitor to a certain internet website called a web page.

5 0
3 years ago
(true or false) fortnite is the best?
GarryVolchara [31]

Answer:

FALSE ZzZzZzZz

Explanation:

Cus it is PERIOT

7 0
3 years ago
Read 2 more answers
What is one reason why private loans are less favorable than federal loans?
Lilit [14]
The answer is higher interest rate
6 0
4 years ago
Read 2 more answers
A disk rotates at a rate of 7200 revolutions per minute. Seek operations (i.e., moving the access head to a desired track) take
Leno4ka [110]

Answer:

24.167 micro seconds.

Explanation:

The given rotation rate = 7200 rpm = 7200 rounds per minute

Rotational latency is the average time taken for the head to reach starting of sector .

Rotational latency (in micro seconds) = (1 / (RPM / 60)) * 0.5 * 1000

(1/(7200/60))* 0.5 * 1000 = 4.167 ms

Thus, rotational latency = 4.167 ms.

Seek time = 20 ms

The average time taken for the access head to get to the beginning of randomly selected sector will be equal to the average time to first reach the random track plus the average time taken to reach random sector .

= 20 ms + 4.167  ms  = 24.167 micro seconds.

Thus, it would take 24.167 micro seconds to get the access head to the beginning of a randomly selected sector on a randomly selected track.

8 0
4 years ago
Other questions:
  • Let's say you want to insert a photo of the Microsoft PowerPoint Ribbon to put into your presentation. Which of these should you
    6·1 answer
  • CHALLENGE ACTIVITY 2.15.1: Reading and outputting strings. Write a program that reads a person's first and last names, separated
    11·1 answer
  • A hot spot is the __________. A. Point that collides with other objects B. Point an object spins around when it rotates C. First
    8·1 answer
  • Sound can be converted from the electrical energy inside a computer into the mechanical energy of soundwaves in air by using
    9·1 answer
  • Major stress in your life can cause:
    11·2 answers
  • Which of the following is something all models use to determine relationships?
    7·1 answer
  • Write a C++ program to print name, age, class, school​
    12·1 answer
  • Which option should Gina click to edit the text contained in a text box on a slide in her presentation?
    10·1 answer
  • You are given the following design parameters, fill in the table: All memory addresses are 32-bit long; A 64Kbyte (2^16 byte) ca
    7·1 answer
  • You're asked to recommend potential data structures to use as the backing for implementing Kruskal's algorithm. Which of the fol
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!