This preview shows page 1. Sign up to view the full content.
Computer Science 130B
Winter 2007
Written Assignment #1
Due: 4pm, January 19th, Friday
Problem 1
In divideandconquer, the way a problem is divided into pieces often a±ects the e±ectiveness
and applicability of the proposed solution. Consider the Towers of Hanoi problem again. De²ne the original
problem as
Hanoi
(
n, A, B, C
)
,
where the ²rst parameter denotes the number of disks, the second parameter the starting peg, the third
parameter the ending peg, and the last parameter the temporary storage peg.
a.
Consider the following divideandconquer strategy:
Hanoi
(
n, A, B, C
)
⇒
Hanoi
(1
, A, C, B
) +
Hanoi
(
n

1
, A, B, C
) +
Hanoi
(1
, C, B, A
)
,
which divides the original problem into
two
instances of size 1 and
one
instance of size
n

1. If you think
the strategy will work, give the detailed motion sequence for Hanoi(4,A,B,C) and estimate the complexity
of the algorithm. If you think the strategy will not work, provide a counterexample.
b.
This is the end of the preview. Sign up
to
access the rest of the document.