W08/CS5592
Homework Three
Design and Analysis of Algorithms
Due: Monday, March 10, 2008, in class
There are four problems
1
Find an optimal parenthesization of a matrix chain product whose sequence of
dimensions is (8, 10, 6, 11, 3, 35).
2
Re-consider the domino stone problem. Suppose that a sequence of
n
(> 1) domino
stones,
s
1
,
s
2
, …,
s
n
, are placed horizontally in a row. Each stone
s
i
(1
≤
i
≤
n
) has two
nonnegative numbers as illustrated by the following figure.
5
6
4
2
9
7
5
7
3
9
11 10
S
1
S
2
S
3
S
4
S
5
S
6
We use arrays
L
[
i
] and
R
[
i
] to store the two numbers of
s
i
(1
≤
i
≤
n
), where
L
[
i
]
is the number arranged to the left side of
R
[
i
] in the sequence. For example, in the
above sequence, we have
L[1] = 5, R[1] = 6,
L[2] = 4, R[2] = 2,
L[3] = 9, R[3] = 7,
L[4] = 5, R[4] = 7,
L[5] = 3, R[5] = 9,
L[6] = 11, R[6] = 10.
If
L
[
i
]
≤
R
[
i
], then we say that stone
s
i
is in state 0, denoted by W[
i
] = 0.
Otherwise, W[