# ProgTeamIS-Hmk2-Combo2-Sol by huangyuarong

VIEWS: 5 PAGES: 6

• pg 1
```									     Programming Team Independent Study Homework Week #2: Combinatorics

n
 n k
1)Evaluate the sum       (1)   k
 10 .
k 
k 0         

n
 n        n
(1) 2n (1) k    n k           n
 n
(1) k  10 k  
 k                        (1) 2k
 10  (1) n   10 k (1) nk  (1) n (10  1) n  (9) n
k                  
k 0                k 0                               k 0  k 

Another, easier way:

n
n         n
 n
(1) k  10 k    (1) nk (10) k  (1  10) n  (9) n
 k                       
k 0                k 0  k 

2) Use combinatorial reasoning to prove the identity below in the form given:

 n   n  3  n  1  n  2   n  3
 k   k    k  1   k  1    k  1  .
                                   
                                    

Consider the following problem: Given the set {1,2,3,…,n}, how many ways are there to
choose k integers from the set such that either 1, 2 or 3 is in each set? The answer to this
n
question is the left-hand side of the equation. We can see this because   is the total
k 
 
number of ways to make those choices. From this, we must subtract out all combinations
 n  3
 k  such combinations from {4,5,6…,n}.
that don’t have 1, 2 or 3. There are       
      

Now, an alternate way to count these subsets is as follows: Count all the subsets that have
1 as their lowest number. To these, add all the subsets that have 2 as their lowest number,
and to these, add all the subsets that have 3 as their lowest number. Clearly there is no
double counting here (since each group has a different starting set value), and clearly all
subsets are counted, since we have not left out any subsets that have a 1, 2 or 3. To get
the number of subsets in the first group, choose 1, which leaves k-1 remaining choices
out of n-1. To get the number of subsets in the second group, choose 2, which leaves k-1
remaining choices out of the n-2 values 3, 4, 5, …, n. Finally, to get the number of values
in the third set, just choose 3, leaving k-1 values to choose from 4, 5, 6, …, n.

3) Prove that for a positive integer n

 n  n  n                       n
   2   3   ...  (1) n1 n   0
 1  2  3                       n
                               
Note: The book from which I pulled this problem had a mistake – this problem was
taken from the Introductory Combinatorics book verbatim. The formula is true for
all integers n > 1, but not true for n = 1. Here is the proof:

n
 n
(1  x) n    ( x) k
 
k 0  k 

d                  d n  n
(1  x) n    ( x) k
dx                 dx k 0  k 
 
n
 n
n(1  x) n1 (1)    k  ( x) k 1
k 
k 1      
n
 n
n(1  x) n1 (1)   (1) k k  ( x) k 1
k 
k 1           
n
 n  k 1
n(1  x) n1   (1) k 1 k  ( x)
k 
k 1             

Now, plug in x = 1 into this formula to yield:

n
 n
n(1  1) n1  0   (1) k 1 k   , the desired result.
k 
k 1           

4) By integrating the binomial expansion, prove that for a positive integer n,

1  n 1  n        1  n  2 n1  1
1        ...       
2  1 3  2
             n 1 n
     n 1

1 n         n
  k x
1
    (1  x) n dx                   k
       dx
0                  0
 
k 0

(1  x) n1 1 n 1  n  k 1 1
|0              x |0
 
n 1          k 0 k  1  k 

(1  1) n1      1        n
1  n
                       , (Note: all subtracted terms are 0.)
n 1        n  1 k 0 k  1  k 
 
n 1
2 1           n
1  n
             
 
n 1       k 0 k  1  k 
5) Every day a student walks from her home to school which is located 10 blocks east
and 14 blocks north from home. She always takes a shortest walk of 24 blocks.

(a)How many walks are possible?

 24
  , you simply choose 10 out of the 24 “moves” you make to go east.
 10 
 

(b) Supposed that 4 blocks east and 5 blocks north of her home lives her best friend
whom she meets each day on her way to school. How many different walks are possible?

 9 15 
   , you must choose east 4 out of the first 9 moves, and then 6 times out of the
 4  6 
  
remaining 15 moves.

(c) Suppose, in addition, that 3 blocks east and 6 blocks north of her friend's house there
is a park where the two girls stop each day to rest and play. How many different walks
are there?

 9  9  6 
    , the reasoning is similar to the reasoning above.
 4  3  2 
   

(d) Stopping at the park to rest and play the two students often get to school late. To
avoid the temptation of the park, our two students decide never to pass the intersection
where the park is. How many different walks are there?

 9  15  9  6 
 (     ) , she still must go 4 blocks east out of the first 9 moves. But, from
 4   6   3  2 
      
15 
there, we must only count the paths that don’t go through the park. There are   total
6
 
 9  6 
paths, but of these, we don’t want to count the    that go through the park.
 3  2 
  
Alternatively, we just subtract our answer from part c from the answer in part b.

6) Determine the number of permutations of {1,2,3,4,...,8} in which exactly 4 integers are
in their natural position. (Feel free to write a program to double check your answer.)

8
  D4  70(9)  630 , we can choose the 4 numbers in place in 8 choose 4 ways. For
 4
 
each of these choices, the other 4 must be “deranged” =) This can be done in D4 number
of ways.
7) At a party 7 men check their hats. In how many ways can their hats be returned so that

(a)no man receives his own hat?

D7 = 1854

(b) at least one of the men receives his own hat?

7! – D7 = 5040 – 1854 = 3186, take all permutations and subtract out the derangements.

(c) at least two of the men receive their own hats?

From the answer in part b, we must subtract out all arrangements where exactly one man
receives his own hat. The one person that gets their hat back can be chosen in 7 ways, and
for each of these choices, the remaining 6 hats can be returned in D6 ways. So, our final

7! – D7 – 7D6 = 3186 – 7(265) = 1331

8) Use combinatorial reasoning to derive the identity

 n      n        n              n           n
n!   Dn    Dn1    Dn2  ...  
 0     1         2                     D1    D0
 n  1       n
                                            

Note: We define D0 = 1 for the purposes of this identity.

The LHS is simply the total number of ways to permute n items.

Now, imagine counting up the total number of permutations of n items by grouping them
by exactly how many items were in there correct place. There would be n+1 groups, 1 for
0 items in place, 1 for 1 item in place, etc. (Technically, note that it’s impossible to have
n-1 items in place exactly, so this group would be empty always.) Consider counting the
number of permutations where exactly k items were in place. We would have to choose
n
the locations for those k items and we could do that in   ways. Then, we would need
k 
 
to derange the following n – k items, which can be done in Dn-k ways. Thus, there are
n
exactly   Dn  k permutations with exactly k items in place. Summing from k = 0 to k =
k 
 
n gives us the RHS of the identity above.
9) Prove the following about the Fibonacci numbers, F(n):

(a)F(n) is even iff n is divisible by 3.

We must prove that F(n) is odd if n ≡ 1 mod 3, or n ≡ 2 mod 3 and even when n is
divisible by three.

Base case(s): n=1,2,3. The conjecture holds for these three cases since F(1) = 1, F(2) = 1
and F(3) = 1.

Inductive hypothesis: Assume for all integers n ≤ k, where k is a arbitrary positive integer
that F(n) is even iff n is divisible by 3.

Inductive hypothesis: Prove for n = k+1 that F(k+1) is even iff k+1 is divisible by 3.

If k+1 is divisible by 3, we have:

F(k+1) = F(k) + F(k-1)
= (2a+1) + (2b + 1), since by the IH, both F(k), F(k-1) must be odd
= 2(a+b+1), which proves F(k+1) is even.

If k+1 is NOT divisible by 3, we have:

F(k+1) = F(k) + F(k-1)
= 2a + 2b + 1, using the IH, we know one of these two is even, the other odd.
= 2(a+b) + 1, proving that F(k+1) is odd in this case, as desired.

(b) F(n) is divisible by 3 iff n is divisible by 4

Consider the sequence F(n) mod 3. The first twelve terms of the sequence are 1, 1, 2, 0, 2,
2, 1, 0, 1, 1, 2, 0. Clearly the sequence repeats every 8 terms, where every 4 th term is
divisible by 3. A formal proof would look similar to the one in part (a).

(c) F(n) is divisible by 4 iff n is divisible by 6

The sequence F(n) mod 4 repeats the cycle 1, 1, 2, 3, 1, 0 infinitely. Using induction can
formally prove this result as well.

(d) F(n) is divisible by 5 iff n is divisible by 5.

The sequence mod 5 has a cycle of length 20: 1, 1, 2, 3, 0, 3, 3, 1, 4, 0, 4, 4, 3 ,2, 0, 2, 2,
4, 1, 0. The conclusion follows from examining this sequence.

(e) Make a conjecture about when F(n) is divisible by 7 and prove it.
F(n) is divisible by 7 iff n is divisible by 8. The cycle (of length 16) mod 7 is as follows:
1, 1, 2, 3, 5, 1, 6, 0, 6, 6, 5, 4, 2, 6, 1, 0.

10) Solve the recurrence relation:

H(n) = H(n-1) + 9H(n-2) + 9H(n-3) for n > 2 with
H(0) = 0, H(1) = 1, H(2) = 2

The characteristic equation has complex roots, so screwed up in making up this
problem. I will correct it for the next homework assignment.

11) Solve the recurrence relation:

H(n) = 4H(n-1) + 3x2n, for n > 0 H(0) = 1

First, let’s solve for the particular solution. We surmise that it is of the form c2n. Plugging
in we get:

c2n = 4(c2n-1) + 3(2n)
c2n = (2c)2n + 3(2n)
c2n = (2c+3)2n

Equating coefficients, we get c = 2c + 3, so c = -3.

Our general solution is just H(n) = c4n.

Now, to solve for the particular, we have:

H(n) = c4n – 3(2n)

H(0) = 1 = c – 3, so c = 4. Our final solution is

H(n) = 4n+1 – 3(2n)

```
To top