Discrete Structures: The Basics of Counting
Discrete Structures: The Basics of Counting
Chapter 5
The Basics of Counting
The Sum Rule
37 + 83 = 120
Example
Total of: 26 * 26 * 26 * 10 * 10 * 10
Example
n!
P(n,r) = n(n-1)(n-2) … (n-r+1) =
(n-r)!
n!
P (n , r )=
(n− r )!
• So our formula for this problem would be:
P(8, 3) = 8! / (8 – 3)! = 8! / 5! = 336
Example
52!
C (52,5 )=
5!(52− 5)!
52! / (5!(52 – 5)!) = 2,598,960
Example
• What are the odds of being dealt a hand of 5-card stud
containing two pair?
• First, let’s look at the steps in the process of forming a 5-card
hand containing two pairs, say 2 eights and 2 aces:
a) Choose two face values out of 13 possible face values for the
pairs (eights and aces):
13 choose 2 = 78
b) Choose two cards from the smaller face value (8♣, 8♠):
4 choose 2 = 6
c) Choose two cards from the larger face value (A♠, A♣):
4 choose 2 = 6
d) Choose one card from those remaining (9♦):
44 choose 1 = 44 (eliminating the 8 face cards already
considered: 52 – 8 = 44)
• By the Product Rule, H = 78 • 6 • 6 • 44 = 123,552.
Example
• H = 123,552 = the number of different
ways we can form a five-card poker hand
containing 2 pair.
• T = 2,598,960 = the total number of
different five-card poker hands that can be
dealt from a standard deck of 52 playing
cards.
• So, the probability of obtaining a hand with
two pairs is H / T = 123,552 / 2,598,960 or
4.75%.
Summary
(x+y)0 = 1
(x+y)1 = x + y
(x+y)2 = x2 + 2xy + y2
(x+y)3 = x3 + 3x2y + 3xy2 + y3
(x+y)4 = x4 + 4x3y + 6x2y2 + 4xy3 + y4
Example
Instead of multiplying, the expansion of (x+y)3
can be found by combinatorial reasoning:
(x+y)3 = (x+y) • (x+y) • (x+y)
j= 0
n
0
¿
ri g h
¿
¿
¿
n
1
¿
ri g h
¿
¿
¿
n
2
¿
ri g h
¿
¿
¿
n
n − 1
¿
ri g h
¿
¿
¿
n
n
¿
ri g h
¿
¿
¿
(¿ )¿
= ¿ ¿
¿
Example
Expand (x + y)4.
4
= ∑
j = 0
4
(x + y)4 j
¿
rig h
¿
¿
¿
(¿)¿
¿¿
4
0
¿
r ig h
¿
¿
¿
4
1
¿
r ig h
¿
¿
¿
4
2
¿
r ig h
¿
¿
¿
4
3
¿
r ig h
¿
¿
¿
4
4
¿
r ig h
¿
¿
¿
(¿ )¿
= ¿ ¿
¿
∑
k = 0
n
k
¿
ri g h
¿
¿
¿
n
0
¿
ri g h
¿
¿
¿
n
1
¿
ri g h
¿
¿
¿
n
2
¿
ri g h
¿
¿
¿
n
n − 1
¿
ri g h
¿
¿
¿
n
n
¿
ri g h
¿
¿
¿
(¿ )¿
¿ ¿
Proof Using Subsets
n
∑
k = 0
n
k
¿
rig h
¿
¿
¿
n
0
¿
ri g h
¿
¿
¿
n
1
¿
ri g h
¿
¿
¿
n
2
¿
ri g h
¿
¿
¿
n
n − 1
¿
ri g h
¿
¿
¿
n
n
¿
ri g h
¿
¿
¿
(¿ )¿
¿ ¿
∑
k = 0
n
k
¿
rig h
¿
¿
¿
n
0
¿
ri g h
¿
¿
¿
n
1
¿
ri g h
¿
¿
¿
n
2
¿
ri g h
¿
¿
¿
n
n − 1
¿
ri g h
¿
¿
¿
n
n
¿
ri g h
¿
¿
¿
(¿ )¿
¿ ¿