CountingCH3
CountingCH3
Counting
Example
In how many ways can you answer a 3 question true/false
quiz?
Example
How many license plates can be made consisting of two
uppercase letters followed by four digits.
(a) with repetitions allowed.
(b) no letter or digit can be repeated?
(c) same as (a), but only vowels and even digits.
Solutions
(a) With repetition: 262 × 104 = 6, 760, 000 license plates
(b) With no repetition: 26 × 25 × 10 × 9 × 8 × 7 license plates
(c) 52 × 54 license plates.
Example
Suppose variable names in a programming language can be
either a single uppercase letter or an uppercase letter followed
by a digit. Find the number of possible variable names.
Example
How many different 7-bit strings are there?
Example
If two dice are thrown once, then find the no of ways in which
we get odd sum.
Solution
1 2 3 4 5 6
1 (1,1) (1,2) (1,3) (1,4 ) (1,5) (1,6 )
2 ( 2,1) (2,2) (2,3) (2,4 ) (2,5) (2,6)
3 (3,1) (3,2) (3,3) (3,4) (3,5) (3,6)
4 (4,1) (4,2) (4,3) (4,4) (4,5) (4,6)
5 (5,1) (5,2) (5,3) (5,4) (5,5) (5.6)
6 (6,1) (6,2 ) (6,3) (6,4) (6,5) (6,6)
Let Si be sum equal to i when i = 3, 5, 7, 9, 11.
S3 = {(1, 2), (2, 1)} ⇒ |A3 | = 2
S5 = {(4, 1), (3, 2), (2, 3), (1, 4)} ⇒ |A3 | = 4
S7 = {(6, 1), (5, 2), (4, 3), (3, 4), (2, 5), (1, 6)} ⇒ |A7 | = 6
S9 = {(6, 3), (5, 4), (4, 5), (3, 6)} ⇒ |A9 | = 4
S11 = {(6, 5), (5, 6)} ⇒ |A9 | = 2
Since S3 , S5 , S7 , S9 and S11 are pairwise disjoint, the
number of ways in which we get odd sum is
|S3 ∪ S5 ∪ S7 ∪ S9 ∪ S11 | = |S3 | + |S5 | + |S7 | + |S9 | + |S11 |
= 18
Note
If a natural number ‘n’ has prime factorization,
Example
Find the number of positive divisors of 600 .
Solution
600 = 31 × 23 × 52
Let k1 = 1, k2 = 3, and k3 = 2. Then
k1 + 1 = 1 + 1 = 2
k2 + 1 = 3 + 1 = 4
k3 + 1 = 2 + 1 = 3
Thus the no of positive divisors of 600 is 2 × 4 × 3 = 24
Permutations
Permutation: n Pr or P(n, r )
Permutation is the number of arrangement of items.
The number of permutation of size r from n items
n!
1 without repetitions is P(n, r ) = (n−r )! .
2 without repetition is P(n, r ) = nr
Order is considered.
Example
How many vectors can be drown using 5 points if any 3 of
them are none colinear?
5! 5!
Solution: P(5, 2) = (5−2)!
= 3!
= 20 vectors.
Example
(a) How many arrangements can be made in the letters of
"COMPUTER"?
8!
Solution: P(8, 8) = (8−8)!
= 8!
Example
How many pairs of dance partners can be selected from a
group of 12 women and 20 men?
20! 20
Solution: P(20, 12) = (20−12)!
= 8!
Example
If |A| = 2 and |B| = 4, then how many
(a) one-to-one functions are there from A to B?
(b) one-to-one functions are there from B to A?
(c) functions are there from A to B?
Solution:
4!
(a) P(4, 2) = (4−2)!
= 12 one to one functions from A to B.
(b) P(2, 4) = 0 : No one to one functions from B to A.
(c) 42 = 16 functions from A to B.
EXAMPLE:
(a) What is the number of permutations of the letters in the
word BANANA?
6!
solution: P(6; 1, 3, 2) = 3!2!
= 60 different arrangements.
EXAMPLE
(a) In how many ways 7 people arranged on a circular table?
Solution: (n − 1)! = (7 − 1)! = 6! = 720.
Restricted permutation:
Permutation of n items in r places when p particular
items will
(n−p)!
1 always occur is P(n − p, r − p) = (n−r )!
(n−p)!
2 never occur is P(n − p, r ) = (n−p−r )!
Example
In how many ways can we choose 11 out of 18 players?
(i) If 2 players are chosen (ii) If 2 players are not chosen
Solution:
(i) P(18-2,11-2)=p(16,9) (ii) P(18-2,11)=p(16,11)
Example
How many permutations of the letters "a, b, c, d, e, f, g, h"
contain "abc" as a block?
Solution
Rename "abc" to B, and the question becomes:
permutations of "Bdefgh." Therefore there are
P(6, 6) = 6! = 720 different arrangements
Example
How many integers can we form with 3,3,4,5,5,6,7 if we want
to exceed 5,000,000?
Example
How many lines can be draw using 5 points if any 3 of them
are none colinear?
5
Solution: C (5, 2) = 2!(5−2)!
= 10 lines
Example
In how many ways can I choose 2 students to be class
representatives from a class of 40 students?
40 40!
Solution: C2 = 2!(40−1)!
= 20 × 39 = 780
Restricted Combinations:
EXAMPLE:
A student is to answer 7 out of 10 questions on an exam.
In how many ways can the student make his selection
(a) if there is no restriction?
(a) if he must answer the first two questions?
(c) if he must answer at least four of the first six questions?
Solution
10 10!
(a) C (10, 7) = 7
= 7!3!
= 120 ways.
10−2 8
(b) 7−2
= 5
= (1)(56) = 56 ways.
(c) There are 3 cases to consider. He may decide to answer
(i) 4 of the first 6 questions and 3 of the last 4 questions
(ii) 5 of the first 6 questions and 2 of the last 4 questions
(iii) 6 of the first 6 questions and 1 of the last 4 questions
6 4
4
+ 65 42 + 66 41 = 100
3
So he can make his selection in 100 different ways.
Example
A committee of 12 is to be selected from 10 men and 10
women. In how many ways can the selection be carried out if
(a) there are no restrictions?
(b) there must be 6 men and 6 women?
(c) there must be an even number of women?
(d) there must be more women than men?
(e) there must be at least 8 men?
EXAMPLE:
There are 3 flavors of ice cream to choose from; vanilla,
chocolate and strawberry. There are 5 children whom each get
to choose their own flavor, but every flavor must be used at
least once. How many different ice cream orders are possible?
Solution
Here, we can assign
child 1 vanilla
child 2 chocolate
child 3 strawberry
The other two children have a choice.
So now we have 3 flavors with only two children left.
! !
3+2−1 4
= =6
2 2
We use combination with repetitions for :
balls in bins
books on shelves
integer solutions
EXAMPLE
Determine the number of integer solutions to
x1 + x2 + x3 = 14, xi ≥ 0 ∀i.
Solution
Here we have 4 bins and 14 balls.
n
= 3, r =14
3+14−1
14
= 16
14
16!
= 2!14! = 8(15) = 120 integer solutions.
EXAMPLE
Determine the number of integer solutions to
x1 + x2 + x3 = 14, xi ≥ 2 ∀i.
Solution
Let xi = yi + 2 for each i = 1, 2, 3.
So we have: y1 + 2 + y2 + 2 + y3 + 2 = 14, yi + 2 ≥ 2.
y1 + y2 + y3 = 8, yi ≥ 0.
So
here
we have 4 bins and 8 balls.
3+8−1 10!
8
= 2!8! = 45
Therefore the equation has 45 integer solutions.
Binomial Coefficients
Binomial Theorem:
n n
!
n n−j j
(x + y )n = C (n, j)x n−j y j =
X X
x y
j=0 j=0 j
n
!
n
x n−j y j
X
=
j=0 n−j
n
The coefficient C (n, j) = j
is called the binomial
coefficient of x n−j y j .
EXAMPLE
What is the coefficient of x 6 y 7 in (2x − 3y )13 ?
13 13
The coefficient of a6 b 7 in (a + b)13 is 6
or 7
13 6 7 13 6 6 7 7 13 6 7
7
a b = 7
2 x (−1) y =−64 7
x y .
So the coefficient of x 6 y 7 is : −64C (13, 7).
Some consequences:
1
n
!
n
2n =
X
j=0 j
2
n
!
n
(−1)j
X
=0
j=0 j
n n−1 n−1
Pascal’s Identity: j
= j−1
+ j
if 1 ≤ j ≤ n − 1.
Multinomial Coefficients:
The coefficient of x1n1 x2n2 x3n3 . . . xtnt in the expansion of
(x1 + x2 + x3 + . . . + xt )n is
n!
n1 !n2 !n3 ! . . . nt !
where each ni is an integer with 0 ≤ ni ≤ n, for all
1 ≤ i ≤ t andn = n1 + n2 + . . . + nt .
n
n1 !n2 !n3 !...nt !
= n1 ,n2n,...,nt is called multinomial
coefficient.
When t=2, this reduces to binomial coefficient.
EXAMPLE:
Determine the coefficients of
4
(a) xyz 2 in (2x − y − z)4 (b) xyz −2 in (x − 2y + 3z −1 )
Solution
(a) Coefficient of xyz 2 :
Variables: x1 = x , x2 = y , x3 = z
n1 = 1, n2 = 1, and n3 = 2 ⇒ n = 1 + 1 + 2 = 4
c1 = 2, c2 = −1, and c3 = −1
[c1n1 c2n2 c3n3 ] n1 !nn!2 !n3 ! = 21 (−1)1 (−1)2 1!1!2!
4!
= −24.
Therefore, the coefficient of xyz 2 in the expansion of
(2x − y − z) is -24.4
EXAMPLE-1
What is the minimum number of people to ensure that 2
people share the same birthday?
k + 1 = 366 + 1 = 367 minimum number of people
EXAMPLE-2:
What is the minimum number of words to ensure that 2
English words start with the same letter?
Solution
k = 26
k + 1 = 26 + 1 = 27 words
Solution
73
k = 12 and N = 73. So = ⌈6.08333⌉ = 7
12
At least 7 people born on the same month.
EXAMPLE-4:
What is the minimum number of students in a class if at least
9 students will get the same letter grade ( A, B, C, D, or F)?
Solution
The boxes are the grades. Thus k = 5.
& '
N
Hence we have = 9 ⇒ N−15
= 9 − 1 ⇒ N = 41
5
The minimum number of students in the class is 41.
EXAMPLE-5:
A bowl contains 10 red and 10 black balls.
(a) How many balls must be selected to ensure 3 balls of the
same color?
(b) How many balls must be selected to ensure 3 black balls?
Solution
l m
N N−1
(a) k = 2 and 2
=3⇒ 2
= 2 ⇒ N = 5 balls .
(b) 13 balls.
EXAMPLE-6:
There are 40 different time periods during which classes at a
university can be scheduled. If there are 615 different classes,
how many different rooms will be needed?
Solution
l m l m
k = 40, N = 615, Nk = 615 40
= ⌈15.375⌉ = 16
At least 16 rooms will be needed.
Example
Assume you have a drawer containing a random distribution of
a dozen brown socks and a dozen black socks. It is dark, so
how many socks do you have to pick to be sure that among
them there is a matching pair?
3.4 Generating functions
n=0
EXAMPLE:
(a) [3, 0, 0, 0, 0, · · · ] ←→ 3.
(b) [1, 2, 3, 0, 0, · · · ] ←→ 1 + 2x + 3x 2 .
(c) For any n ∈ N,
n n n n
(i) 0 , 1 , 2 , · · · , n , 0, · · · ←→
(1 + x ) = 0 + 1 x + n2 x 2 + · · · + nn x n .
n n n
n+1
(ii) [1, 1, · · · 1, 0, · · · ] ←→ 1−x 2 n
1−x = 1 + x + x + · · · + x .
(d) [1, 1, 1, 1, 1, · · · ] ←→ 1 + x + x 2 + x 3 + x 4 + · · ·.
What is the Generating function of the sequence: [1, 1, 1, · · · ]?
Recall:
1
1
1−y
= 1 + y + y 2 + y 3 + y 4 + · · · ←→ [1, 1, 1, 1, · · · ]
1
2
(1−y )2
= 1 + 2y + 3y 2 + 4y 3 + · · · ←→ [1, 2, 3, 4, · · · ]
2
3
(1−y )2
= 2 + 4y + 6y 2 + 8y 3 + · · · ←→ [2, 4, 6, 8, · · · ]
1+y
4
(1−y )2
= 1 + 3y + 5y 2 + 7y 3 + · · · ←→ [1, 3, 5, 7, · · · ]
1
4) Substitute x 2 for y in (1−y )2
= 1 + 2y + 3y 2 + 4y 3 + · · ·
1
(1−x 2 )2
= 1 + 2x 2 + 3x + 4x 6 + · · ·
2
2
∴ (1−ax )2
is the generating function for 2, 4a, 6a2 , 8a3 , · · ·
Shifting or Multiply by x k , k = 1, 2, · · · , n
1
1) Multiply by 1−x
= 1 + x + x 2 + x 3 + · · · by x :
x 2 + x3 + x4 + · · ·
1−x = x + x
x
∴ 1−x is the generating function for 0, 1, 1, 1, · · ·
1
2) Multiply by (1−x )2
= 1 + 2x + 3x 2 + 4x 3 + · · · by x :
x
(1−x )2
= x + 2x 2 + 3x 3 + 4x 4 + · · ·
x
∴ (1−x )2
is the generating function for 0, 2, 3, 4, · · ·
d x d
= x + 2x 2 + 3x 3 + 4x 4 + · · ·
dx (1 − x )2 dx
3)
1+x
= 1 + 22 x + 32 x 2 + 42 x 3 + · · ·
(1 − x )3
1+x
∴ (1−x )3
is the generating function for 11 , 22 , 32 , 42 , · · ·
x (1+x )
4) (1−x )3
generates the sequence 0, 22 , 32 , 42 , · · ·
x (1+x )
(1−x )3
= x + 22 x 2 + 32 x 3 + 42 x 4 + · · ·
x
5) + (1−x )2
= x + 2x 2 + 3x 3 + 4x 4 + · · ·
2x
= 2x + 6x 2 + 12x 3 + 20x 4 + · · ·
(1−x ) 3
2x
∴ (1−x )3 generates the sequence 2, 6, 12, 20, · · ·
Multiplication:
EXAMPLE
(a) A boy is allowed to choose two items from a basket
containing two apples, an orange, a pear, a banana, and a
plum. How many ways can this be done?
(b) A boy is allowed to choose two items from a basket
containing two apples, an orange, a pear, and a banana.
How many ways can this be done if we consider the two
apples to be identical?
Solution
(a) The boy choose
2 from a set of 5 items, the number of
ways is 52 = 2!(5−2)!
5!
= 10
The boy may choose 0 or 1 apple, orange, pear, banana
and plum, for a total of 2 items. The number of doing
this exactly the coefficient x 2 in
(1 + x ) (1 + x ) (1 + x ) (1 + x ) (1 + x )
| {z } | {z } | {z } | {z } | {z }
apple orange pear banana plum
(1 + x )5 = x 0 + 5x 1 + 10x 2 + 10x 3 + 5x 4 + x 5
The boy can choose no item in 1 way, 1 item in 5 ways, 2
items in 10 ways, 3 items in 10 ways, 4 items in 5 and 5
items in 1 way.
= 1 + 4x + 7x 2 + 7x 3 + 4x 4 + x 5
The boy can choose 2 items in the basket in 7 ways.
Exercise
1 A software team has 10 senior members and 10 junior
members. Must select a set of 4 people to work on a
project. How many selections have at least one junior
member?
2 How many integer solutions are there to the equation
x1 + x2 + x3 + x4 = 12, xi ≥ 0, x2 ≤ 3, and x4 ≥ 2
1 x4
(b) 1−x + 3x 7 − 11 (d) 1
3−x (f) 1−x