Given two strings x = x1x2 xn and y = y1y2 ym, we wish to find the length of their | StudySoup

Textbook Solutions for Algorithms

Chapter 6 Problem 6.8

Question

Given two strings x = x1x2 xn and y = y1y2 ym, we wish to find the length of their longestcommon substring, that is, the largest k for which there are indices i and j with xixi+1 xi+k1 =yjyj+1 yj+k1. Show how to do this in time O(mn).

Solution

Step 1 of 3

Consider two sequences, ,  and Z as the longest common substring of X and Y with length K.

The indices i and j are two strictly increasing sequence from 1,2,....K .  Therefore,  

Subscribe to view the
full solution

Title Algorithms  1 
Author Sanjoy Dasgupta Algorithms, Christos H. Papadimitriou Algorithms, Umesh Vazirani Algorithms
ISBN 9780073523408

Given two strings x = x1x2 xn and y = y1y2 ym, we wish to find the length of their

Chapter 6 textbook questions

×

Login

Organize all study tools for free

Or continue with
×

Register

Sign up for access to all content on our site!

Or continue with

Or login if you already have an account

×

Reset password

If you have an active account we’ll send you an e-mail for password recovery

Or login if you have your password back