hwk11 Sol
hwk11 Sol
Fall 2005
Homework #11
Due 12/04/05, 8a
43 Points
1. (10 Points) The Master Theorem (Rosen, p 430) states: Let f be an increasing
function that satisfies the recurrence relation
f (n) a f (n /b) cn d
whenever n b k , where k is a positive integer, a 1, b is an integer greater than
1, and c and d are real numbers with c positive and d nonnegative. Then
O(n d )
if a b d
logb a
O(n
)
if a b d
We will prove the Master Theorem by solving the following parts (some of the
answers can be found in your book. See exercises 29-33 on p 435).
a. Show that if a b d and n is a power of b, then
e. Use part c. to show that if a > bd, then f (n) O(n log b a ) .
Solution:
a. Suppose n=bk. Then
f (n) f (b k ) a f (b k 1 ) cb kd a (a f (b k 2 ) cb ( k 1) d ) cb kd a 2 f (b k 2 ) acb( k 1) d cb kd
...
k 1
k 1
j 0
k 1
k 1
k 1
j 0
j 0
j 0
To prove that the expression above is indeed big-o of the dominant factor, note that
you can easily find N starting from which, the dominant factor is larger then both of
the other factors. Thus, the c-constant for big-o (not to confuse with the c-constant of
the master theorem) is 3*c, and the big-o inequality holds for all n larger then N.
c. This one will be by induction on n, or rather k, where n=bk.
Induction base: k=0; n=1.
log b a
C1n d C2 nlog b a thus f (n) 2C2 nlog b a O(nlog b a ) . Likewise, if a < bd,
C1n d C2 nlog b a thus f (n) 2C2 n d O(n d ) .
Grading Rubric: each section is worth 2 points. One for incomplete answer, two for a
complete one.
2. (16 points) Determine whether the relation R on the set of all real numbers is
reflexive, symmetric, antisymmetric, and/or transitive, where (x,y) R if and
only if
a.
b.
c.
d.
e.
f.
g.
h.
Answers:
x + y = 0.
x = y.
x y is a rational number.
x = 2y.
xy 0.
xy = 0.
x = 1.
x = 1 or y = 1.
a. Not reflexive, for example, 2+2 is not equal to 0. Symmetric, because if x+y=0
then y+x=0. Not antisymmetic. Not transitive, for example, 1+-1=0 and 1+1=0
but 1+1=2.
b. Reflexive (x=x), symmetric (x = y entails y = x), not antisimetric, transitive: if
x = y and y = z then clearly x = z.
c. Reflexive (x-x=0 is rational), symmetric (if x-y=z is rational, then y-x=-z which is
also rational), not antisimmetric, not transitive, for example (1+,-), (-,).
d. Not reflexive, not symmetric, antisymmetric, not transitive.
e. Reflexive, symmetric, not antisymmetric, not transitive (2,0), (0,-6).
f. Not reflexive, symmetric, not transitive. For example, x=1, y=0, z=1.
g. Not reflexive, not symmetric, antisymmetric, transitive.
h. Not reflexive, symmetric, not antisymmetric, not transitive. For example,
x=10,y=1,z=10.
Grading Rubric: each section is worth 2 points. One for incomplete answer, two for a
complete one.
3. (10 points) Let R1 and R2 be the divides and is a multiple of relations on the
set of all positive integers, respectively. That is, R1 = {(a,b) | a divides b} and R2
= {(a,b) | a is a multiple of b}. Find:
a.
b.
c.
d.
e.
R1 R2,
R1 R2,
R1 R2,
R2 R1,
R1 R2.
Answers:
a. Either a divides b, or it is the multiple of b. That is either a divides b or b divides
a. We can formulate this relation as GCD(a,b)=min{a,b}.
b. Both a divides b and b divides a. Thus a=b.
c. a divides b and a<b (ab).
d. b divides a, a>b (ab).
e. GCD(a,b)=min{a,b} and ab
Grading rubric:
2 point for each correct answer.
4. (7 points) How many transitive relations are there on a set with n elements if
a. (2 points) n = 1?
b. (3 points) n = 2?
c. (2 points) n = 3?
Answers:
a. There can be only one reflexive relation that would be also symmetric and
transitive.
b. Suppose we have two elements: {1,2}. We can have the following 15 relations:
{(1,1)} ; {(2,2)} ; {(2,1)} ; {(1,2)} ; {(1,1), (1,2)}; {(1,1),(2,1)}; {(1,1),(2,2)};
{(1,2),(2,1)}; {(1,2),(2,2)}; {(2,1),(2,2)}; {(1,1),(2,2),(2,1)}; {(1,1),(2,2)(1,2)};
{(1,1),(2,1),(1,2)}; {(2,2),(1,2), (2,1)}; {(1,1),(1,2),(2,1),(2,2)}. There are three
non-transitive relations: {(1,2),(2,1)}; {(1,1),(2,1),(1,2)}; {(2,2),(1,2), (2,1)}.
Thus there are 12 transitive relations.
c. Unfortunately one cannot solve this problem without the help of a computer. You
were to write a program that gives a correct answer: 171