Assignment #4, CS/531
Due Date: Mon. Nov. 7, 2011
UNSUPPORTED SOLUTIONS RECEIVE NO CREDIT.
Total points: 51
1 (7 pts). Maximum Contiguous Subsequence Sum Problem revisited.
Let
A
[1
..n
] be an array of numbers. The elements in
A
can be either positive or negative.
We want to find the indices
k, l
so that the sum
∑
l
i
=
k
A
[
i
] is maximum among all possible
choices of
k, l
.
For example if
A
=
{−
3
,
12
,
−
6
,
10
,
−
5
,
2
}
, the answer is
k
= 2
, l
= 4, since
A
[2] +
A
[3] +
A
[4] = 12 + (
−
6) + 10 = 16 is the maximum sum of all possible choices.
This is exactly the problem 3 in HW2. However, this time you must describe an
O
(
n
) time
algorithm for solving this problem.
2. (1 pt) Consider the graph
G
= (
V, E
) shown in Figure 1. The integers near an edge is its
weight. Using Kruskal’s algorithm, compute the minimum spanning tree
T
1
of
G
. List the edges
of
T
1
in the order they are added into
T
1
.
5
3
2
6
4
7
1
8
6
3
4
2
a
b
c
d
e
f
h
g
Figure 1: Kruskal’s Algorithm.
3. (6 pts) For a given undirected, edge weighted graph
G
= (
V, E
), there might be more than
one MST of
G
. This can happen if
G
has two edges
e
′
and
e
′′
such that
w
(
e
′
) =
w
(
e
′′
). In this
case, when we run Kruskal algorithm on
G
, the edges
e
′
and
e
′′
may be processed in different
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.
 Fall '11
 XINHE
 Algorithms, Graph Theory, pts, base station, Kruskal's algorithm, alphabetical order

Click to edit the document details