# CMPSCI 311: Theory of Algorithms

### Fall, 2003

Here are questions and answers on HW#4, due 17 October 2003. Questions are in black, answers in blue.

#### Question 5, 16 October 2003

In 5.2.3, should we assume that the graph in question is undirected, since in section 5.2 all the graphs are undirected?

Yes.

#### Question 4, 16 October 2003

In 5.1.2, it's easy to solve this problem by a loop instead of recursion, is this ok?

No, the point of the problem is to use the decrease-by-one form to solve the problem. You must give an algorithm for the n-element case that makes a recursive call on the same algorithm for the (n-1)-element case, and uses this answer to find its own answer. Then analyze the algorithm using a recurrence of the form "T(n) = T(n-1) + f(n)", with the appropriate f(n) and an appropriate base case.

#### Question 3, 16 October 2003

In 5.1.1, can one of the boys operate the boat by himself?

Yes, if not it would be easy to prove that the problem is insoluble. The boat may contain one boy, both boys, or one soldier.

#### Question 2, 16 October 2003

For 4.6.9, in the text he talks about S2 as being to the left of the line from Pmax to Pn, but in figure 4.8 these points are shown to the right of that line. Is this a typo?

No, the line from Pmax to Pn is heading southeast on the page, so its left is to the northeast of it, as is shown on the figure correctly.

#### Question 1, 16 October 2003

In 4.5.7, may we use ordinary matrix multiplication to multiply the two-by-twos by each other?

Yes, this is what Levitin means by stopping the recursion at n=2.