#  problems  

1  GT Exercise R1.7 on page 42
Order the following list of functions by the bigOh notation. group together those functions that are θ( ) of one another.


2  GT Exercise R1.17 on page 44,
but assume that f (n) and g(n) are nonnegative functions.
Show that O( max{ f (n), g(n)} ) = O ( f (n)+g(n) ).  
3  GT Exercise R13.2 on page 392 Let G be a simple connected graph with n vertices and m edges. Explain why O(log m) is O(log n).  
4  CLRS Exercise C.33 on page 1200
A carnival game consists of three dice in a cage. A player can bet a dollar on any of the numbers 1 through 6. The cage is shaken, and the payoff is as follows. If the player's number doesn't appear on any of the dice, he loses his dollar. Otherwise, if his number appears on exactly k of the three dice, for k = 1, 2, 3, he keeps his dollar and wins k more dollars. What is his expected gain from playing the carnival game once? 

5  CLRS Exercise A.21 on page 1156
Show that ∑_{k=1 to n} ( 1/k^{2} ) is bounded above by a constant. 

6  GT Exercise C1.4 on page 45
What is the total running time of counting from 1 to n in binary if the time needed to add 1 to the current number i is proportional to the number of bits in the binary expansion of i that must change in going from i to i+1? 

7  GT Exercise C3.12 on page 112 (Note that, in GT, log means log_{2})
Without using calculus, show that, if n is a power of 2 greater than 1, then, for H_{n}, the nth harmonic number, H_{n} ≤ 1 + H_{n/2}. Use this fact to conclude that H_{n} ≤ 1 + ⌈lg n⌉, for any n ≥ 1. 

8  GT Exercise C1.8 on page 45 Al and Bill are arguing about the performance of their sorting algorithms. Al claims that his O(n log n)time algorithm is always faster than Bill's O(n^{2})time algorithm. To settle the issue, they implement and run the two algorithms on many randomly generated data sets. To Al's dismay, they find that if n < 100, the O(n^{2})time algorithm actually runs faster, and only when n > 100 is the O(n log n)time algorithm better. Explain why this scenario is possible. You may give numerical examples. 

9  Resolve the following questions, with proof:


10  The following is known about functions f and g:

#  hard problems 

11  Prove by induction that, for all n ≥ 6, the unit square can be partitioned into n squares (not necessarily of identical size). 
12 
Consider the following induction "proof" that all sheep in a flock are the same color:
Base case: One sheep. It is clearly the same color as itself. Induction step: A flock of n sheep. Take a sheep, a, out of the flock. The remaining n1 are all the same color by induction. Now put sheep a back in the flock, and take out a different sheep, b. By induction, the n1 sheep (now with a in their group) are all the same color. Therefore, a is the same color as all the other sheep; hence, all the sheep in the flock are the same color. What is wrong with this "proof"? 
13 
Consider the following "proof" that the Fibonacci function, F(n), defined as
F(1) = 1, F(2) = 2, F(n) = F(n1) + F(n2), is O(n):
Base case (n ≤ 2): F(1) = 1, which is O(1), and F(2) = 2, which is O(2). Induction step (n > 2): Assume the claim is true for all n' < n. Consider n. F(n) = F(n1)+F(n2). By induction, F(n1) is O(n1) and F(n2) is O(n2). Then, F(n) is O((n1) + (n2)), by the identity presented in Exercise R1.16. Therefore, F(n) is O(n), since O((n1)+(n2)) is O(n). What is wrong with this "proof"? 
14 
You are given values x, y_{1}, ..., y_{n} that are distinct integers
randomly chosen with equal probability from 1 to 2n.
The following is an efficient comparisonbased algorithm that determines whether x
has value greater than all of the y_{j}.
Compare x one at a time to each of y_{j} until either (1) a comparison indicates that one of the y_{j} > x, in which case return the answer NO, or (2) comparisons with every one of the y_{j} indicate that x > y_{j}, in which case return the answer YES. Determine the averagecase number of comparisons performed by this algorithm. 