CSIS 0250B Design and Analysis of Algorithms
Assignment 3
Due: 11:55 PM, Mar 12, 2009
1. Given positive integers
a
1
,a
2
,
···
,a
n
, devise a dynamic programming algorithm to determine
whether it is possible to divide the
n
integers into three disjoint subsets with equal sum
(which should be equal to
1
3
∑
n
i
=1
a
i
). Your algorithm should run in time polynomial in
n
and
U
=
∑
n
i
=1
a
i
.
2. Consider the problem of neatly printing a paragraph on a typewriterquality printer, which
supports a character set
A
and prints a character
a
∈
A
with ﬁxed (horizontal) space
f
(
a
). We
assume that the space character occupies 1 unit of space (i.e.
f
(“ ”)=1). For example, printing
two words “abc” and “bca” with one space character in between requires 2(
f
(
a
)+
f
(
b
)+
f
(
c
))+1
units of space.
The input text is a sequence of
n
words
w
1
,w
w
,...,w
n
, each formed by one or more characters
from
A
. We want to print this text neatly on a number of lines, each holds a maximum
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '10
 Chan
 Algorithms, Dynamic Programming, Graph Theory, C Programming, Equals sign, optimal alignment score

Click to edit the document details