Beruflich Dokumente
Kultur Dokumente
RPI
2014
ASSIGNMENT 6
1
n
P
i. What is the Big-Theta, Big-Oh and Little-Oh relationship between g(n) and n, n2 , n3 .
i=1
n
X
i=0
1
1 + i2
(3) A recursive function takes an input of size n reduces it to two problems of size n/2 and does extra work
of n to combine the results to get the output. The running time depends only on n, the size of the input.
Let T (n) be the time to run on any input of size n. Show that
T (n) = 2T (n/2) + n.
(4) Find formulas for:
m
n X
X
i=1 j=1
(i + j);
m
n X
X
i+j
m
n Y
Y
3i+j .
i=0 j=0
i=0 j=0
(5) Tn = 2Tn1 Tn2 + 2; T0 = 1; T1 = 2. Use the method of differences to conjecture a formula for Tn
and then prove your formula by induction.
(6) Prove that if a divides bc and GCD(a, b) = 1 then a divides c.
n
P
i=1
i
i2 +1
(mod p) or x y
(mod p). Is
(4) T (n) = 2 T (n/2) + n. Let n = 2k . Show that T (n) = (n log n). [Hint: Induction. Show that
T (n) c1 n log n and T (n) c2 n log n for constants c1 , c2 .]
(5) Let p be prime. Prove that if p divides a1 a2 ak then p divides one of the ai .
[Hint: Warm up problem 6.]
(6) Consider all permutations of {1, 2, 3, 4, 5, 6}. A permutation is good if any of the sub-sequences 12, 23
or 56 appear. How many good permutations are there?
n
P
i=1
b2
g1
g3
g2
b3
g1
g2
g3
g1
b1
b3
b2
g2
b2
b3
b1
g3
b3
b1
b2
Use the dating algorithm from class to find a stable set of marriages:
(a) With the boys being the wooers and the girls the deciders.
(b) With the girls being the wooers and the boys the deciders.
Define the regret for a person as how far away from their top choice they got married. For example, if
a marriage is b1 g3 then regret(b1 ) = 2 and regret(g3 ) = 1. Compute the total regret for the boys and
girls using the stable marriages you got from parts (a) and (b).
[FYI (you do not have to show this): The regret for each girl will never be more for (b) than (a), and
the reverse is true for the boys. Be the side that makes the first move!]
(4) Let S be a set of n + 1 distinct numbers chosen from the set {1, 2, . . . , 2n}.
(a) Estimate the number of ways to choose S when n = 100. Use an approximation for n! that we
derived in class.
(b) Show that no matter what S you choose, there are two numbers x, y S with GCD(x, y) = 1.
[Hint: GCD(k, k + 1) = 1.]
(5) Prove or disprove:
There exists n 3 for which there are preferences of n boys and n girls such that every
matching is stable.
If you think the claim is true, give the preferences of the n boys and n girls and show that every matching
is stable. If you think it is false, prove it - show that for any set of preferences and any n 3 there is
at least one unstable matching.
Prove or disprove: 2p 1 is prime when p is prime. The student gave a faulty proof by induction and got zero points.
Student (to prof ): Why did I get 0 points?
Prof (to student): Look, the claim is clearly false: 211 1 = 2047 which is not prime (2047 = 23 89).
Student (to prof ): Hmm. . . your proof seems correct, but so what? The question said Prove OR disprove. You choose to
prove and I choose to disprove.
/
2