This preview shows pages 1–2. Sign up to view the full content.
W07/CS592
Suggested Solutions to
Homework Three
Design and Analysis of Algorithms
Due: Mar. 6, 2007
There are 5 problems
1
.
Find an optimal parenthesization of a matrix chain product whose sequence of
dimensions is (7, 11, 4, 9, 3, 16).
2
Page 356, Exercise 15.45.
Give an O(
n
2
)time algorithm to find the longest monotonically increasing
subsequence of a sequence of
n
numbers.
3
Two character strings may have many common substrings. For example,
establish
and
stability
have common strings
s
,
st
,
sta
,
stab
,
l
,
li
,
ab
, etc.
The longest one is
stab
. Let X =
x
1
x
2
…
x
n
and Y =
y
1
y
2
…
y
m
be two character strings. Give a
dynamic programming algorithm to find the longest common substring for X and
Y.
Note.
A common string is different from a common subsequence. A common
string must contain consecutive characters in both X and Y. You only need to
show the formula by which you can construct the solution, and the initial values.
Detailed coding is not required.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Winter '05
 Shen
 Algorithms

Click to edit the document details