# CMPSCI 311: Theory of Algorithms

### Fall, 2003

Here are questions and answers on HW#3, due 26 September 2003. Questions are in black, answers in blue.

#### Question 4, 25 September 2003

In 3.3.6, do we need to give a rigorous proof that the examples exist, or is it sufficient to give an example in terms of m and n, with m, n arbitrary and m ≤ n?

You need to prove that your example actually has the property it's supposed to, but if you describe the example in terms of an arbitrary n and m with m ≤ n then that's fine, because that is a proof that the example exists for all such m and n (by the rule for proving "for all" statements covered in CMPSCI 250).

#### Question 3, 25 September 2003

May I use exponentiation as an operation in Problem 3.1.4?

No! While a high-level language might give you exponentiation of integers as a primitive operation, it is very unlikely that your computer can implement exponentiation in one clock cycle. So here you must show how to calculate the powers involved by individual multiplications.

#### Question 2, 23 September 2003

2 questions:

1) In question 2.5.9 part a, I cannot make out this Cassini's ID function as it is described. Perhaps you could elaborate? For example, one part is [f(n)]^2. If f(n) = (-1)^n, then isn't that always 1? Using this formula to interpret the meaning of f(n-i), with regards to the entire identity, one gets an answer that is always 0.

It doesn't say that F(n) = (-1)^n, it says that F(n+1)F(n-1) - [F(n)^2] is (-1)^n, where F(n) is the n'th Fibonacci number. For example, if n=2 the identity says that F(3)F(1) - F(2)^2 = (-1)^2 = 1, which is true because 2*1 - 1^2 = 1. For n=5 it says F(6)F(4) - F(5)^2 = -1, which is true as 8*3 - 5^2 = -1.

2) Question 3.4.7- It seems to be implied that the two disjoint subsets will use all of the elements of N, but this is not stated. I can think of a nice optimization and approach for solving the question using all of the elements of N, but it is quite a bit more complex if any two disjoint subsets of N can be used.

The word "partition" is meant to imply that all elements are used. So assume that the union of the two disjoint subsets is the entire set of n elements.

#### Question 1, 19 September 2003

I'm getting an early start on HW3 and I've run into a snag with 2.2.9 -- I can't seem to find a foothold with which to prove the inductive step of part A: that f(n) = f(n+1)*f(n-1) - [f(n)]^2 = (-1)^n implies f(n+2)*f(n) - [f(n+1)]^2 = (-1)^n+1.

I feel like I have a good handle on what the identity means and how it's used, I just can't seem to see how it is proven... perhaps you could suggest some properties of fib. numbers to look at?

Nearly all Fibonacci identities are proved using the inductive part of the definition: F(n+1) = F(n) + F(n-1), possibly in related forms such as F(n+2) = F(n+1) + F(n) or F(n) = F(n-1) + F(n-2). With an identity like this you'll want to get both sides in terms of the same quantities -- you can't get them all in terms of one quantity but you could do two, like F(n-1) and F(n-2) or something.