Programming Assignment 3
Points: 500
Due: April 22, 11:59PM
Late Submission April 23, 11:59PM (25% penalty)
Description of a programming assignment is not a linear narrative and may require multiple
readings before things start to click. You are encouraged to consult instructor/Teaching Assis
tants for any questions/clariFcations regarding the assignment. Your programs must be in Java,
preferably Java 8.1.
All your classes must be in the
default package
(even though it is not a good programming
practice). ±or this PA, you
may work in teams of 2
. It is your responsibility to Fnd a team
member. If you can not Fnd a team member, then you must work on your own.
1 Dynamic Programming
You will use dynamic programming to compute
min cost vertical cut
of a matrix and to perform
string alignment
. You will design a class named
DynamicProgramming
.
1.1 Cuts
Let
M
be a
n
⇥
m
integer matrix (with
n
rows and
m
columns). Assume that rows are numbered
0
,
1
,
2
,
···
,n

1 and columns are numbered 0
,
1
,
2
,
···
m

1. Let
M
[
i, j
]referstothece
l
lin
i
th row
and
j
th column. A
vertical cut
V
of
M
is a sequence of 2
n
integers [
x
0
,y
0
,x
1
,y
1
,
···
,x
n

1
,y
n

1
]
such that the following holds
1.
x
0
= 0,
y
0
2
{
0
,
···
,m

1
}
2. ±or 1
i<n
,
x
i
=
x
i

1
+1
3. ±or 1
i<ny
i
2
{
y
i

1
,y
i

1

1
,y
i

1
+1
}
The
cost of a vertical cut
V
=[
x
0
,y
0
,x
1
,y
1
,
···
,x
n
,y
n
] is deFned as
Cost
(
V
)=
M
[
x
0
,y
0
]+
M
[
x
1
,y
1
]+
···
+
M
[
x
n

1
,y
n

1
]
Given a matrix, the
mincost vertical cut
, denoted
MinVC
(
M
), is a vertical cut whose cost is the
smallest.
1