Counting Principles - Material
Counting Principles - Material
Generating Functions:
Introductory Examples, Definitions and Examples: Calculation Techniques, Partitions of Integers, The
Exponential Generating Functions, The Summation Operator.
---------------------------------------------------------------------------------------------------------------------------------------------
The first principle says that the whole is the sum of its parts.
Sum Rule:
the | X | = | S | + | S | + ….. + | Sn |.
If the su sets S , S , ….,S e e allo ed to o e lap, the a o e p ofou d p i iple ill e eeded the
principle of inclusion and exclusion.
The difference is largely in semantics, for if A is an event, we can let X be the set of ways that A
can happen and count the number of elements in X. Nevertheless, let us state the sum rule for counting
events.
If E , ……, E a e utuall e lusi e e e ts, a d E a happe e a s, E happe e a s,….
Again we emphasize that mutually exclusive events E1 and E2 mean that E1 or E2 can happen
but both cannot happen simultaneously.
The sum rule can also be formulated in terms of choices: If an object can be selected from a
reservoir in e1 ways and an object can be selected from a separate reservoir in e2 ways and an object
can be selected from a separate reservoir in e2 ways, then the selection of one object from either
one reservoir or the other can be made in e1 + e2 ways.
Product Rule:
If S , …..,S are o e pt sets, the the u er of ele e ts i the Cartesia produ t is
S S ….. S is the produ t ∏i = |S i |.
Observe that there are 5 branches in the first stage corresponding to the 5 elements of S1 and to
each of these branches there are 3 branches in the second stage corresponding to the 3 elements of S2
giving a total of 15 branches altogether. Moreover, the Cartesian product S1 x S2 can be partitioned as
(a1 x S2) U (a2 x S2) U (a3 x S2) U (a4 x S2) U (a5 x S2), where (ai x S2)
= {( ai, b1), ( ai, b2), ( ai, b3)}.
Thus, for example, (a3 x S2) corresponds to the third branch in the first stage followed by each of the 3
branches in the second stage.
Mo e ge e all , if a ,….., a a e the disti t ele e ts of S a d ,…., a e the disti t
elements of S2, then S1 x S2 = Uin =1 (ai x S2).For if x is an arbitrary element of S1 x S2 , then x = (a, b)
where a Î S1 and b Î S2.
Thus, a = ai for some i and b = bj for some j. Thus, x = (ai, bj) Î(ai x S2) and therefore x Î Uni =1(ai x S2).
Conversely, if x Î Uin =1(ai x S2), then x Î (ai x S2) for some i and thus x = (ai, bj) where bj is some
element of S2. Therefore, x Î S1 x S2.
Therefore, The product rule is for two sets. The general rule follows by mathematical induction.
We a refor ulate the produ t rule i ter s of e e ts. If e e ts E , E , …., E a
Happened in e , e ,…., a d e a s, respe ti ely, then the sequence of events E1 first, followed by
E ,…., follo ed E a happe e e …e a s.
In terms of choices, the product rule is stated thus: If a first object can be chosen e1 ways, a
se o d e a s , …, a d a th o je t a e ade i e e ….e a s.
Note that we are simply defining the terms r-combinations and r-permutations here and
have not mentioned anything about the properties of the n objects.
For example, these definitions say nothing about whether or not a given element may appear more
than once in the list of n objects.
In other words, it may be that the n objects do not constitute a set in the normal usage of the word.
SOLVED PROBLEMS
Example1. Suppose that the 5 objects from which selections are to be made are: a, a, a, b, c. then the
3-combinations of these 5 objects are :aaa, aab, aac, abc. The permutations are:
aaa, aab, aba, baa, aac, aca, caa, abc, acb, bac, bca, cab, cba.
Neither do these definitions say anything about any rules governing the selection of the r-
objects: on one extreme, objects could be chosen where all repetition is forbidden, or on the other
extreme, each object may be chosen up to t times, or then again may be some rule of selection between
these extremes; for instance, the rule that would allow a given object to be repeated up to a certain
specified number of times.
We will use expressions like {3 . a , 2. b ,5.c} to indicate either
(1) that we have 3 + 2 + 5 =10 objects including 3a’s , 2b’s and 5c’s, or
(2) that we have 3 objects a, b, c, where selections are constrained by the conditions that a can be
selected at most three times, b can be selected at most twice, and c can be chosen up to five times.
aac, abb,abc,
ccc, ccb, cca, cbb.
In order to include the case where there is no limit on the number of times an object
can be repeated in a selection (except that imposed by the size of the selection) we use the symbol
∞ as a epetitio u e to ea that a o je t a o u a i fi ite u e of ti es.
Example5 The combinations of a ,b, c, d with unlimited repetitions are the 3-combinations of
{∞ . a , ∞. , ∞. , ∞. d}. These are su h -combinations, namely: aaa,
aab, aac, aad,
2-permutations
2-combinations with Unlimited Repetitions
with Unlimited
Repetitions
Aa aa
Ab ab, ba
Ac ac, ca
Ad ad, da
Bb bb
Bc bc, cb
Bd bd, db
Cc cc
Cd cd, dc
Dd dd
10 16
Of course these are not the only constraints that can be placed on selections
The possibilities are endless. We list some more examples just for concreteness. We might, for
example, consider selections of {∞.a, ∞. , ∞. } here a e hose o l e e number of times.
Thus, 5-combinations with these repetition numbers & this constraint would be those 5-Combinations
with unlimited repetitions and where b is chosen 0, 2, or 4 times.
While there may be an infinite variety of constraints, we are primarily interested in two major
types: one we have already described—combinations and permutations with unlimited repetitions,
the other we now describe.
If the repetition numbers are all 1, then selections of r objects are called r-combinations
without repetitions and arrangements of the r objects are r-permutations without repetitions.
We remind you that r-combinations without repetitions are just subsets of the n elements containing
exactly r elements. Moreover, we shall often drop the repetition number 1 when considering r-
combinations without repetitions. For example, when considering r-combinations of {a, b, c, d} we will
mean that each repetition number is 1 unless otherwise designated, and, of course, we mean that in a
given selection an element need not be chosen at all, but, if it is chosen, then in this selection this
element cannot be chosen again.
Example7. Suppose selections are to be made from the four objects a, b, c,d.
2-combinations 2-Permutations
withoutRepetitions withoutRepetitions
ab ab,ba
ac ac, ca
ad ad, da
bc bc, cb
bd bd, db
cd cd, dc
6 12
There are six 2-combinations without repetitions and to each there are two 2-
permutations giving a total of twelve 2-permutations without repetitions.
Note that total number of 2-combinations with unlimited repetitions in Example 5
included six 2-combinations without repetitions of Example.7 and as well 4 other 2-
combinations where repetitions actually occur. Likewise, the sixteen 2-permutations with
unlimited repetitions included the twelve 2-permutations without repetitions.
abc, acb, bac, bca, cab, cbaabd, adb, bad, bda, dab, dbaacd, adc, cad, cda, dac, dcabcd, bdc, cbd,
cdb, dbc, dcb are 24
Note that to each of the 3-combinations without repetitions there are 6 possible 3- permutations
without repetitions. Momentarily, we will show that this observation can be generalized.
5.1.4 Combinations and Permutations with Repetitions:
General formulas for enumerating combinations and permutations will now be presented. At this
time, we will only list formulas for combinations and permutations without repetitions or with unlimited
repetitions. We will wait until later to use generating functions to give general techniques for
enumerating combinations where other rules govern the selections.
Let P (n, r) denote the number of r-permutations of n elements without repetitions.
Proof. Since there are n distinct objects, the first position of an r-permutation may be filled in n ways.
This done, the second position can be filled in n-1 ways since no repetitions are allowed and there are n
– 1 objects left to choose from. The third can be filled in n-2 ways. By applying the product rule, we
conduct that
P (n, r) = n(n-1)(n- ……. – r + 1). From the definition of factorials, it follows that
P (n, r) = n! / (n-r)!
When r = n, this formula becomes
P (n, n) = n! / 0! = n!
When we explicit reference to r is not made, we assume that all the objects are to be arranged;
thus we talk about the permutations of n objects we mean the case r=n.
Corollary1. There are n! permutations of n distinct objects.
Example1. There are 3! = 6 permutations of {a, b,c}.
Example 2 There are P (10, 4) = 5,040 4-digit numbers that contain no repeated digits since each
such number is just a arra ge e t of four of the digits , , , , …., 9 leadi g zeroes are
allowed). There are P (26, 3) P(10, 4) license plates formed by 3 distinct letters followed by 4 distinct
digits.
Example3. In how many ways can 7 women and 3 men be arranged in a row if the 3 men must
always stand next to each other?
Solution :
There are 3! ways of arranging the 3 men. Since the 3 men always stand next to each other, we
treat them as a single entity, which we denote by X.
The if W , W , ….., W7 represents the women, we next are interested in the number of ways
of a a gi g {X, W , W , W ,……., W }. The e a e ! Pe utatio s these o je ts. He e the e a e
(3!) (8!) permutations altogether.
Example4.In how many ways can the letters of the English alphabet be arranged so that there are
exactly 5 letters between the letters a and b?
There are P (24, 5) ways to arrange the 5 letters between a and b, 2 ways to place a and b, and
then 20! ways to arrange any 7-letter word treated as one unit along with the remaining 19 letters. The
total is P (24, 5) (20!) (2).
Permutations for the objects are being arranged in a line. If instead of arranging objects in a line, we
arrange them in a circle, then the number of permutations decreases.
Binomial Coefficients:
k
In mathematics, the binomial coefficient is the coefficient .of the x term in the polynomial
n.
expansion of the binomial power (1 + x) In combinatorics , is interpreted as the number of k-
element subsets (the k-combinations) of an n-element set, that is the number of ways that k things can be
"chosen" from a set of n things.
Hence, is often read as "n choose k" and is called the choose function of n and k. The
notation was introduced by Andreas von Ettingshausenin 182, although the numbers were already
n
known centuries before that (see Pascal's triangle). Alternative notations include C(n, k), nCk, Ck,, in all
of which the C stands for combinations or choices.
For natural numbers (takentoinclude0)n and k, the binomial coefficient can be defined as
k n
the coefficient of the monomial X in the expansion of (1 + X) . The same coefficient also occurs
(ifk ≤ n) in the binomial formula
(valid for any elements x, y of a commutative ring), which explains the name "binomial coefficient".
Another occurrence of this number is in combinatorics, where it gives the number of ways, disregarding
X
order, that a k objects can be chosen from among n objects; more formally, the number of k-element
subsets (or k-combinations) of an n-element set. This number can be seen to be equal to the one of the
first definition, independently of any of the formulas below to compute it: if in each of the n factors of
n
the power (1 + X) one temporarily labels the term X with an index i (running from 1 to n), then each
subset of k indices gives after expansion a contribution k , and the coefficient of that monomial in the
result will be the number of such subsets. This shows in particular that is a natural number for any
natural numbers n and k. There are many other combinatorial interpretations of binomial coefficients
(counting problems for which the answer is given by a binomial coefficient expression), for instance the
number of words formed of n bits (digits 0 or 1) whose sum is k, but most of these are easily seen to be
equivalent to counting k-combinations. Several methods exist to compute the value of without
actually expanding a binomial power or counting k-combinations.
5.3.1.2 Binomial & Multinomial theorems:
Binomial theorem:
In elementary algebra, the binomial
ax theorem describes the algebraic expansion of powers of a binomial.
n
According to the theorem, it is possible to expand the power (x + y) into a sum involving terms of the
b c
form , where the coefficient of each term is a positive integer, and y the sum of the exponents of x
and y in each term is n. For example,
The coefficients appearing in the binomial expansion are known as binomial coefficients. They
x are
y
the same as the entries of Pascal's triangle, and can be determined by a simple formula involving
factorials. These numbers also arise in combinatorics, where the coefficient of x,y is equal to the
number of different combinations of k elements that can be chosen from an n- element set.
According to the theorem, it is possible to expand any power of x + y into a sum of the form as
A variant of the binomial formula is obtained by substituting 1 for x and x for y, so that it involves
only a single variable. In this form, the formula reads
or equivalently
Multinomial theorem:
In mathematics, the multinomial theorem says how to write a power of a sum in terms of
powers of the terms in that sum. It is the generalization of the binomial theorem to polynomials.
For any positive integer m and any nonnegative integer n, the multinomial formula tells us how a
polynomial expands when raised to an arbitrary power:
The summation is taken over all sequences of nonnegative integer indices k1 through km such the sum of
all ki is n. That is, for each term in the expansion, the exponents must add up to n.
0
Also, as with the binomial theorem, quantities of the form x that appear are taken to equal 1
(even when x equals zero). Alternatively, this can be written concisely using multi indices as
α α α α
The above equation can be represented by Venn diagram as shown below, where
N (c1c2 ) N (c1 c2 )
1. Say x satisfies no condition. x is counted once on the left side and once on the right side.
2. Say x satisfies c1. It is not counted on the left side. It is counted once in N and once in N(c1).
3. Say x satisfies c2 and c4. It is not counted on the left side. It is counted once in N, N(c2), N(c4) and
N(c2c4).
4. Say x satisfies c1, c2 and c4. It is not counted on the left side. It is counted once in N, N(c1), N(c2),
N(c4), N(c1c2), N(c1c4), N(c2c4) and N(c1c2c4).
5. Say x satisfies all conditions. It is not counted on the left side. It is counted once in all the subsets
on the right side.
N (c1 c2 c3 c4 ) =
Example:
Determine the number of positive integer’s n where n100 and n is not divisible by 2, 3 or 5.
1. Condition c1 if n is divisible by 2.
2. Condition c2 if n is divisible by 3.
3. Condition c3 if n is divisible by 5.
Determine the number of nonnegative integer solutions to the equation x1+x2+x3+x4=18 and xi7
for all i. We say that a solution x1, x2, x3, x4 satisfies condition ci if xi>7.
Then the answer to this problem is
Theorem:
The Above Equation can be represented by using SK
Consider a set S with |s| = N and conditions satisfy some of the elements of S
If m belongs to S then
=S1-C(2,1)S2+C(3, 2)S3
E2=N(c1c2)+N(c1c3)+N(c2c3)-3N(c1c2c3)
=S2-3S3=S2-C(3, 1)S3
E3=S3
E3=S3-C(4,1)S4
E4=S4
Theorem : For each 1<=m<=t , the number of elements in S that exactly given m of the
conditions c1 ,c2, c3, …. C t is give by
Let Lm denotes the number of elements in S that satisfy at least m of the t conditions.
If m pigeons are put into m pigeonholes, there is an empty hole if there's a hole with more than one
pigeon. If n > m pigeons are put into m pigeonholes, there's a hole with more than one pigeon.
Example:
Consider a chess board with two of the diagonally opposite corners removed. Is it possible to cover the
board with pieces of domino whose size is exactly two board squares?
Solution
No, it's not possible. Two diagonally opposite squares on a chess board are of the same color.
Therefore, when these are removed, the number of squares of one color exceeds by 2 the number of
squares of another color. However, every piece of domino covers exactly two squares and these are of
different colors. Every placement of domino pieces establishes a 1-1 correspondence between the set of
white squares and the set of black squares. If the two sets have different number of elements, then, by
the Pigeonhole Principle, no 1-1 correspondence between the two sets is possible.
Generalizations of the pigeonhole principle
A generalized version of this principle states that, if n discrete objects are to be allocated to m
containers, then at least one container must hold no fewer than objects, where is the
ceiling function, denoting the smallest integer larger than or equal to x. Similarly, at least one
container must hold no more than objects, where is the floor function, denoting the
largest integer smaller than or equal to x.
A probabilistic generalization of the pigeonhole principle states that if n pigeons are randomly
put into m pigeonholes with uniform probability 1/m, then at least one pigeonhole will hold more
than one pigeon with probability
where (m)n is the falling factorial m(m − m − ... m − n + 1). For n = 0 and for n = 1 (and m >
0), that probability is zero; in other words, if there is just one pigeon, there cannot be a conflict. For n
>m (more pigeons than pigeonholes) it is one, in which case it coincides with the ordinary pigeonhole
principle. But even if the number of pigeons does not exceed the number of pigeonholes (n ≤ m), due
to the random nature of the assignment of pigeons to pigeonholes there is often a substantial chance
that clashes will occur. For example, if 2 pigeons are randomly assigned to 4 pigeonholes, there is a
25% chance that at least one pigeonhole will hold more than one pigeon; for 5 pigeons and 10 holes,
that probability is 69.76%; and for 10 pigeons and 20 holes it is about 93.45%. If the number of holes
stays fixed, there is always a greater probability of a pair when you add more pigeons. This problem is
treated at much greater length at birthday paradox.
A further probabilistic generalization is that when a real-valued random variable X has a finite
mean E(X), then the probability is nonzero that X is greater than or equal to E(X), and similarly the
probability is nonzero that X is less than or equal to E(X). To see that this implies the standard
pigeonhole principle, take any fixed arrangement of n pigeons into m holes and let X be the number of
pigeons in a hole chosen uniformly at random. The mean of X is n/m, so if there are more pigeons than
holes the mean is greater than one. Therefore, X is sometimes at least2.
Applications:
The pigeonhole principle arises in computer science. For example, collisions are inevitable in a
hash table because the number of possible keys exceeds the number of indices in the array. No
hashing algorithm, no matter how clever, can avoid these collisions. This principle also proves that any
general-purpose lossless compression algorithm that makes at least one input file smaller will make
some other input file larger. (Otherwise, two files would be compressed to the same smaller file and
restoring them would be ambiguous.)
5.2.3 Derangements: nothing is in its right place
e-1=1-1+(1/2!)-(1/3!)+(1/4!)- / ! +….. = .
Let ci be the condition that integer i is in the i-th position. d10 can be computed as
follows.
1 1 1 1
d n n![1 1 .... ]
2! 3! 4! n!
=> d n n!e 1
Problem : We have seven books and seven reviewers. Each book needs to be reviewed by two
persons. How many ways can we assign the referees?
In Figure below, we want to determine the number of ways in which k rooks can
be placed on the unshaded squares of this chessboard so that no two of them can take
each other—that is, no two of them are in the same row or column of the chessboard.
This number is denoted as rk(C).
In Fig , we have r0=1, r1=6, r2=8, r3=2 and rk=0 for k4.
r(C, x)=1+6x+8x2+2x3. For each k0, the coefficient of xk is the number of ways we can
place k nontaking rooks on chessboard C.
Disjoint subboards :
In below Figure the chessboard contains two disjoint subboards that have no squares
in the same column or row of C.
Below fig shows a seating arrangement of seating to 4 persons in 5 tables in forbidden places.
The shaded square of RiTj means Ri will not sit at Tj.
Problems : Determine the number of ways that we can seat these four relatives on un-shaded
squares.
Let S be the total number of ways we can place these four relatives, one to a table.
Let ci be the condition that Ri is seated in a forbidden position but at different tables.
T1 T2 T3 T4 T5
R1
R2
R3
R4
Let ri be the number of ways in which it is possible to place i nontaking rooks on the shaded
chessboard. For all 0i4, Si=ri(5-i)!
=1+7x+16x2+13x3+3x4
N (c1 c2 c3 c4 ) S 0 S1 S 2 S3 S 4
5!7(4!) 16(3!) 13(2!) 3(1!)
4
(1)i ri (5 i )!
i 0
Problem : We roll two dice six times, where one is red die and the other green die.
We know the following pairs did not occur: (1, 2), (2, 1), (2, 5), (3, 4), (4, 1), (4, 5) and (6, 6).
What is the probability that we obtain all six values both on red die and green die?
One of solutions is like (1, 1), (2, 3), (4, 4), (3, 2), (5, 6), (6, 5).
6
5.3 Generating Functions
5.3.1 Introductory Examples
Grace gets at least four, and Mary and Frank gets at least two, but Frank gets no more
than five. (x4+ x5+ x6+ x7+ x8) (x2+ x3+x4+ x5+ x6)(x2+ x3+x4+ x5) Then The coefficient of the
Problem is x12
Grace gets at least four, and Mary and Frank gets at least two, but Frank gets no more than five.
(x4+ x5+ x6+ x7+ x8) (x2+ x3+x4+ x5+ x6)(x2+ x3+x4+ x5)
Problem 3 : How many nonnegative integer solutions are there for c1+c2+c3+c4=25?
For n, the number of 2’s can be kept tracked by the power series 1+x2+x4+x6+x8+….
For n, the number of 3’s can be kept tracked by the power series 1+x3+x6+x9+x12+….
i1[1 /(1 xi )]
Problem : Find the number of ways an advertising agent can purchase n minutes if the time
slots come in blocks of 30, 60, 120 seconds.
a+2b+4c=2n
Problem :
pd(n) is the number of partitions of a positive integer n into distinct summands.
Pd(x)=(1+x)(1+x2)(1+x3 ..…
Problem :
Pd(x)= Po(x)
Problem
poo(n) is the number of partitions of a positive integer n into odd summands and
such summands must occur an odd number of times.
Important Series:
Problem :
We have 48 flags, 12 each of the colors red, white, blue and black. Twelve flags are
placed on a vertical pole to show signal.
How many of these use an even number of blue flags and an odd number of black flags?
Solution:
Then
Let f(x)=a0+a1x+a2x2+a3x3+…. The f / -x) generate the sequence of a0, a0+a1, a0+a1+a2,
a0+a1+a2+a3,…
Problem:
g(x)= 1/(1-x)=1+x+x2+x3+x4+…
q(x)=dg(x)/dx=1/(1-x)2=1+2x+3x2+4x3+.…
r(x)=xq(x)=x/(1-x)2 = x+2x2+3x3+4x4+.…
xdr(x)/dx=(1+x)/(1-x)3= x+22x2+32x3+42x4+.
x(1+x)/(1-x)4 = x+(12+22)x2+(12+22+32)x3+(12+22+32+42)x4+.…