Homework 6 Solutions - Department of Computer Science

Transcription

Homework 6 Solutions - Department of Computer Science
Discrete Math in Computer Science
CS 30, Winter 2015
Homework 6 Solutions by Prasad Jayanti
Max Points: 96
Solutions
1. (4 points) Find the coefficient of x8 y 9 in (3x + 2y)17 .
Solution: By the binomial theorem, the coefficient of the x8 y 9 term in (3x + 2y)17 is 38 29 ·
17
8
.
2. (8 points) Give a formula for the coefficient of xk in (x2 − 1/x)100 .
Solution: By the binomial theorem:
(x2 − 1/x)100 =
100
P
=
i=0
100
P
100
i
(−1)i
i=0
=
(x2 )i (−x−1 )100−i
100
P
100
i
x3i−100
(−1)(100+k)/3
(k+100)/3=0
Thus, the coefficient of xk is (−1)(100+k)/3
100; otherwise, the coefficient of xk is 0.
100
(100+k)/3
xk
100
(100+k)/3
if (k + 100)/3 ∈ Z and 0 ≤ (k + 100)/3 ≤
(letting k = 3i − 100)
3. (4+6 = 10 points) How many solutions are there to the equation x1 + x2 + x3 = 100, where x1 ,
x2 , and x3 are non-negative integers with
(a) x1 > 10, x2 > 15, and x3 > 20
Solution: First give 11 units to x1 , 16 to x2 , and 21 to x3 . We use the stars and bars technique
to divide the remaining 52 units (“stars”) into three parts using two “bars”.
The number of ways is 52+2
= 54
52
52 .
(b) x1 > 10, x2 > 15, and x3 < 40. Express your answer in as simple a form as possible.
Solution: The constraint on x3 —“<” instead of “>”—which makes the problem more challenging than the earlier part, can be taken care of by observing that the answer is the difference between the number of solutions to the system x1 > 10, x2 > 15, and x3 ≥ 0 and the
number of solutions to the system x1 > 10, x2 > 15,and x3≥ 40. Using the starts and bars
35
technique as in the earlier problem, the answer is 75
73 − 33 .
4. (6 points) Prove that nk kj = nj n−j
k−j
(a) by algebraic manipulation.
(b) using a combinatorial argument.
Solution:
(a)
n
k
k
j
=
=
=
=
n!
k!
k!(n−k)! · j!(k−j)!
n!
(n−k)!(k−j)!j!
(n−j)!
n!
· (n−k)!(k−j)!
j!(n−j)!
n n−j
j k−j
(b) Let S be a set of n elements. Then, nk kj is the number of ways of choosing a k-elements
set A from S and then choosing a j-elements set B from A. We can do it in another manner:
first we choose the j-elements set B from S directly and then choose the rest k-j elements
from S − B to form set A along with the j-elements set B. The second manner has nj n−j
k−j
ways. Thus we conclude nk kj = nj n−j
k−j .
5. (6 points) If S is a set with n elements, what is the cardinality of the set {(A, B) | A ⊆ B ⊆ S}?
n
Solution: The number of subsets of S of size m is m
. Each such subset has 2m subsets. There
P
Pn
n
n m n−m
n m
= (2 + 1)n = 3n .
fore, the answer is m=0 m 2 = m=0 m 2 1
Alternatively, for each element of S we have three choices: (i) don’t include the element in A or
B, (ii) include the element in B, but not in A, or (iii) include the element in both B and A. Then,
by the product principle, the total number of possibilities is 3 × 3 × . . . × 3 = 3n .
6. (9 points) A standard deck of cards contains four suits of thirteen kinds of cards, for a total of 52
cards. The cards are the numbers 2 through 10 as well as four face cards, namely, jack, queen,
king, and ace. What is the probability that a five-card poker hand
(a) has the ace of diamonds and the queen of spades?
(b) is a straight flush? A straight is five cards that have consecutive kinds. Note that an ace can
be considered as the lowest or highest card, but not both. Thus, A, 2, 3, 4, 5 is a straight, and
so is 10, J, Q, K, A, but Q, K, A, 2, 3 is not a straight. A flush is five cards of the same suit.
A straight flush is a straight and a flush.
(c) contains three of a kind? (The remaining two cards are required to be of a different kind than
the three, but there is no other restriction; in particular, the two cards can be of the same kind
or of different kinds.)
Solution:
The sample space is S = {A ⊆ D | |A| = 5}, where D is the deck of 52 cards Thus |S| =
52
5
.
(a) The event of interest E1 = {A ∈ S | A has Diamond-A, Spades-Q, and three
other cards}.
|E1 |=50
Since the three cards can be chosen from the remaining 50 cards in 50
ways,
.
3
3
50
|E1 |
3
≈ 0.0075.
Hence, P (E1 ) =
= 52
|S|
5
(b) The event of interest E2 = {A ∈ S | A has five consecutive cards from the same suit}.
There are 4 suits and, in each suit, there are 10 straights (A2345, 23456, . . . , 10JQKA). So,
by Product rule, the number of straight flushes |E2 | = 4 × 10 = 40. Hence, P (E2 ) =
|E2 |
40
= 52 ≈ 1.54 × 10−5 .
|S|
5
(c) Let E3 be the event {A ⊆ S | exactly three cards of A are of same kind k and the other two cards
are of kinds other than k}. There are 13 possibilities for k and, for each possible k, there are
4
of kind k. Hence, by Product Rule, the three cards of same
3 ways of selecting three cards
kind can be chosen in 13 × 43 ways. The remaining two cards in 48
2 ways. Therefore, by
|E3 |
Product Rule, |E3 | = 13 × 43 × 48
2 . Finally, P (E3 ) = |S| ≈ 0.023.
7. (6 points) To play Powerball, America’s largest lottery, a player picks any five distinct integer
numbers from 1 to 55 and an additional number called the Powerball number from 1 to 42 (it is
possible that the powerball number is the same as one of the other five numbers picked) . The
player wins the jackpot if he/she matches all six numbers announced at the drawing that consist
of five distinct numbers from 1 to 55 and a powerball number number from 1 to 42. (The order
is not important for the five numbers, so the set of five numbers of the player must match the set
of five winning numbers, and the player’s powerball number should match the winning powerball
number.)
(a) What is the probability of winning the jackpot?
(b) What is the probability of matching exactly five (which might include the powerball number)
out of the six numbers?
Solution:
(a) For all parts of this problem, the sample space is
S = {({a, b, c, d, e}, f ) |a, b, c, d, e are distinct integers
between 1 and 55, and f is an integer between 1 and 42} .
42
So, |S| = 55
5 × 1 .
Let E ⊆ S denote the event of obtaining the jackpot combination. Since only one combina|E|
tion of numbers wins the jackpot, |E| = 1. So, P (E) =
≈ 6.84 × 10−9 .
|S|
(b) Let E be the event that exactly 5 of the 6 numbers match. Then, for each elementary event
in E, either the five regular numbers match and the powerball number does not match or
exactly four of the five regular numbers match and the powerball
number matches. For the
5
former, there are 1×41 possibilities. For the latter, there are 4 ways of selecting which four
numbers match and 50 ways of selecting the fifth number (since it must
be different from the
five regular numbers of the jackpot); so, by Product Rule, there are 54 × 50 ways. Then, by
|E|
≈ 1.99 × 10−6 .
Sum Rule, |E| = 41 + 54 × 50 = 291. Therefore, P (E) =
|S|
8. (6 points) What is the probability of the following events when we randomly select a permutation
of {1, 2, 3}? Assume uniform probability distribution and use symmetry to solve this problem.
(a) 1 precedes 3
(b) 3 precedes 1
(c) 3 precedes 1 and 3 precedes 2.
Solution:
The sample space S = {123, 132, 213, 231, 312, 321}. |S| = 6.
(a) Let E1 be the event that 1 precedes 3. In every permutation either 1 precedes 3 or 3
precedes 1; hence, P (1 precedes 3) + P (3 precedes 1) = 1. Since the probability distribution is uniform, by symmetry P (1 precedes 3) = P (3 precedes 1). Hence, we have:
P (1 precedes 3) = P (3 precedes 1) = 0.5.
(b) As argued above, P (3 precedes 1) = 0.5.
(c) P (3 precedes 1 and 3 precedes 2) = P (3 precedes both 1 and 2). Since some number must
precede the other two in any permutation, we have:
P (3 precedes both 1 and 2)+P (1 precedes both 2 and 3)+P (2 precedes both 3 and 1) = 1 .
Further, since the probability distribution is uniform, by symmetry P (3 precedes both 1 and 2) =
P (1 precedes both 2 and 3) = P (2 precedes both 3 and 1). Solving the above two equations, we have P (3 precedes both 1 and 2) = 1/3.
9. (6 points) Suppose you know a family has two children.
(a) What is the probability that the family has two girls, if you are told that one of the children
is a girl.
(b) What is the probability that the family has two boys, if you are told that the older child is a
boy.
Solution:
(a) Let A be the event that the family has two girls, and A0 the event that one of the children is a
girl.
|A ∩ A0 |
P (A ∩ A0 )
|A ∩ A0 |
|{GG}|
1
|S|
P (A|A0 ) =
=
=
=
=
0
0
0
|A
|
P (A )
|A |
|{BG, GB, GG}|
3
|S|
(b) Let C be the event that the family has two boys, and C 0 the event that the older child is a boy.
|C ∩ C 0 |
P (C ∩ C 0 )
|C ∩ C 0 |
|{BB}|
1
|S|
P (C|C 0 ) =
=
=
=
=
0
0
0
|C |
P (C )
|C |
|{BG, BB}|
2
|S|
10. (9 points) Suppose that the experiment is to flip a fair coin thrice. For each of the following pair of
events, use the definition of independence to determine whether the events are independent. Show
your work.
(a) E1 : the first coin comes up tails; E2 : the second coin comes up heads.
(b) E1 : the first coin comes up tails; E2 : two, and not three, heads come up in a row.
(c) E1 : the second coin comes up tails; E2 : two, and not three, heads come up in a row.
Solution:
The sample space S = {HHH, HHT, HT H, HT T, T HH, T HT, T T H, T T T }.
|S| = 8.
(a) E1 = {T HH, T HT, T T H, T T T } and E2 = {HHH, HHT, T HH, T HT }.
E1 ∩ E2 = {T HH, T HT }.
We have:
P (E1 ) = |E1 |/|S| = 4/8 = 0.5
P (E2 ) = |E2 |/|S| = 4/8 = 0.5
P (E1 ∩ E2 ) = |E1 ∩ E2 |/|S| = 2/8 = 0.25
Since P (E1 ∩ E2 ) = 0.25 = P (E1 )P (E2 ), the events E1 and E2 are independent.
(b) E1 = {T HH, T HT, T T H, T T T } and E2 = {HHT, T HH}. E1 ∩ E2 = {T HH}.
We have:
P (E1 ) = |E1 |/|S| = 4/8 = 0.5
P (E2 ) = |E2 |/|S| = 2/8 = 0.25
P (E1 ∩ E2 ) = |E1 ∩ E2 |/|S| = 1/8 = 0.125
Since P (E1 ∩ E2 ) = 0.125 = P (E1 )P (E2 ), the events E1 and E2 are independent.
(c) E1 = {HT H, HT T, T T H, T T T } and E2 = {HHT, T HH}. E1 ∩ E2 = ∅.
We have:
P (E1 ) = |E1 |/|S| = 4/8 = 0.5
P (E2 ) = |E2 |/|S| = 2/8 = 0.25
P (E1 ∩ E2 ) = |E1 ∩ E2 |/|S| = 0/8 = 0
Since P (E1 ∩ E2 ) 6= P (E1 )P (E2 ), the events E1 and E2 are not independent.
11. (6 points) Show that if E and F are independent events, then E and F are also independent events.
Solution:
Assume E and F are independent, i.e., P (E ∩ F ) = P (E)P (F ). Then:
P (E ∩ F ) = P (E ∪ F )
DeMorgan’s Law: E ∩ F = E ∪ F
= 1 − P (E ∪ F )
= 1 − (P (E) + P (F ) − P (E ∩ F ))
= 1 − (P (E) + P (F ) − P (E)P (F )) since E and F are independent
= 1 − P (E) − P (F ) + P (E)P (F )
= (1 − P (E))(1 − P (F ))
= P (E)P (F )
Hence, E and F are independent.
12. (3+4+5=12 points) Suppose we roll 8 dice. What is the probability that everyone of the numbers
1 . . . 6 appears on top at least once? Solve the problem in steps, as follows:
(a) Let Ei be the event that i does not show up on any of the dice. Now state the question in
terms of Ei .
T
(b) What is P (Ei ∩ Ej ) for any i 6= j? Generalize to
Ei for I ⊆ {1, 2, 3, 4, 5, 6}.
i∈I
(c) Solve the problem using the principle of inclusion-exclusion.
Solution:
(a) The sample space S = {1, 2, 3, 4, 5, 6}8 and |S| = 68 . We assume that the probability
distribution is uniform.
!
6
6
S
S
The question asks for P
Ei = 1 − P
Ei
i=1
i=1
{i, j})8 .
(b) Ei ∩ Ej = ({1, 2, 3, 4, 5, 6} −
Therefore, |Ei ∩ Ej | = 48 , and
8
|Ei ∩ Ej |
4
=
P (Ei ∩ Ej ) =
|S|
6
T
Generalizing,
Ei = ({1, 2, 3, 4, 5, 6} − I)8
i∈I
Ei | = (6 − |I|)8 , and
T
Ei | |
T
6 − |I| 8
i∈I
Ei =
P
=
|S|
6
i∈I
(c) Let J = {1, 2, 3, 4, 5, 6}.
6
T
P
S
|I|+1
Ei
(−1)
P
Ei =
P
i=1
i∈I
∅⊆I⊆J
P
6 − |I| 8
|I|+1
=
(−1)
6
∅⊆I⊆J
6
P
6−i 8
=
(−1)i+1 6i
6
i=1
≈ 0.8860
Therefore, |
T
i∈I
Principle of inclusion/exclusion
substituting the result from part b
there are
6
i
subsets of J of size i
Therefore, the answer is 1 − P (∪6i=1 Ei ) ≈ 0.1140
13. (8 points) Find each of the following probabilities when n independent Bernoulli trials are carried
out with probability of success p.
(a) the probability of no failures.
(b) the probability of at least one failure.
(c) the probability of at most one failure.
(d) the probability of at least two failures.
Solution:
If the n Bernoulli trials are conducted, the sample space S = {S, F }n and |S| = 2n .
By Product Rule, for all s ∈ S, P (s) = pk (1 − p)n−k , where k is the number of successes in s.
Since there nk strings in S that have exactly k S’s, the probability of k successes is nk pk (1 −
p)n−k .
(a) Probability of no failure = pn .
(b) Probability of at least one failure = 1 - probability of no failure = 1 − pn .
(c) Probability
of at most one failure = probability of no failure + probability of one failure =
pn + n1 (1 − p)pn−1 = pn + npn−1 (1 − p).
(d) Probability of at least two failures = 1 - probability of at most one failure =
1 − pn − npn−1 (1 − p).