i CMPSCI 311 Q&A on HW#2, Fall 2003

# CMPSCI 311: Theory of Algorithms

### Fall, 2003

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

#### Question 3, 16 September 2003

I have a question about problem 2.2.3. In the book, the problem asks us to indicate the big-Theta class that the functions belong to. However, on the web site, you have stated to give explicit numbers for c and n0 for the big-O notation. Should we be proving the big-O class or the big-Theta, in which case we need to define a c1, c2 and n0?

Yes, you're right, you're asked to prove big-Theta and to prove big-Theta you need three numbers, not two. (By the definition you need a c and an n0 for the big-O, and then another c (positive) and another n0 for the big-Omega. But a single n0 that works for both is fine, and in fact if there are two n0's then the larger one must work for both.

I'll fix this on the assignment page. Thanks for catching it!

#### Question 2, 15 September 2003

May we use limits to prove #2.2.4b?

Yes, this is exactly what I meant by encouraging you to use "the calculus-based methodology on page 54". You may quote facts from a calculus course, like L'Hopital's rule, without proof.

#### Question 1, 14 September 2003

In Question 2.2.8 it simply says "Prove this section's theorem for Big-Omega and Big-Theta".

The theorem in question states: "if t1(n) is in Big-Oh(g1(n)) and t2(n) is in Big-Oh(g2(n)), then t1(n) + t2(n) is in Big-Oh(max(g1(n),g2(n))"

For Big-Omega, it seems pretty obvious, you're trying to prove that t1(n) + t2(n) is in Big-Omega(min(g1(n),g2(n)))

A sensible idea but actually he means for you to prove it for the max.

But what are we supposed to prove for Big-Theta?

Are we to say that t1(n) + t2(n) are in Big-Theta(some function g(n)), iff t1 and t2 are both big-theta of the same g(n) (not separate g1(n) and g2(n) as with Big-Oh and Big-Omega)? Or that t1(n) + t2(n) are in Big-Oh(max(g1,g2)) and are also in Big-Omega(min(g1,g2))?

I thought this was a mistake when I first read it as well, but it's not. In fact you can use "max" in all three versions, i.e., let h = max(f,g):

If t_1 in Omega(f) and t_2 in Omega(g), then t_1+t_2 is in Omega(h)

and thus it follows immediately that

if t_1 in Theta(f) and t_2 in Theta(g), then t_1+t_2 is in Theta(h).

In fact f+g is alway Theta(h).