CSC 203 - Lecture 4
CSC 203 - Lecture 4
0 APPLICATIONS TO COUNTING
CONTENTS
1.0 Introduction
2.0 Objectives
3.0 Main Content
3.1 The Product and Sum Rules
3.2 Permutations and Combinations
3.3 Combinatorial Identities
3.3.1 Using Pascal’s triangle to expand a binomial expression
3.4 Inclusion-Exclusion Principle
4.0 Conclusion
5.0 Summary
6.0 Tutor-Marked Assignment
7.0 References/Further Reading
1.0 Introduction
Counting is a basic mathematical tool that has uses in many diverse circumstances.
How much RAM can a 32-bit register address? How many poker hands form full
houses compared to flushes? How many ways can ten-coin tosses end up with four
heads? To count, we can always take the time to enumerate all the possibilities;
but even just enumerating all poker hands is already daunting, let alone all 32-bit
addresses. This unit discusses some techniques that serve as useful shortcuts for
counting.
2.0 Objectives
By the end of this unit, you will be able to:
• apply product and sum rules
• discuss permutation and combination
• use Pascal’s triangle to expand a binomial expression
• identify and apply inclusion-exclusion and pigeonhole principle.
3.0 Main Content
3.1 The Product and Sum Rules
The product and sum rules represent the most intuitive notions of counting.
Suppose there are n(A) ways to perform task A, and regardless of how task A is
performed, there are n(B) ways to perform task B.
Then, there are n(A) n(B) ways to perform both task A and task B; this is the
product rule. This can generalize to multiple tasks, e.g., n(A) n(B) n(C) ways
to perform task A, B, and C, as long as the independence condition holds, e.g., the
number of ways to perform task C does not depend on how task A and B are done.
Example 3.1.1. On an 8 × 8 chess board, how many ways can I place a pawn and
a rook?
Example 3.1.1. 1. First I can place the pawn anywhere on the board; there are 64
ways. Then I can place the rook anywhere except where the pawn is; there are 63
ways. In total, there are 64 × 63 = 4032 ways.
Example 3.1.2. On an 8 × 8 chess board, how many ways can I place a pawn and a
rook so that the rook does not threaten the pawn?
Solution 3.1.2. Firstly, I can place the rook anywhere on the board; there are 64
ways. At the point, the rook takes up on square, and threatens 14 others (7 in its
row and 7 in its column). Therefore, I can then place the pawn on any of the 64 −
14 − 1 = 49 remaining squares. In total, there are 64 × 49 = 3136 ways.
Example 3.1.3. If a finite set A has n elements, then |P(A)| = 2n.
Solution 3.1.3. We can proof this by using the product rule. P(A) is the set of all
subsets of A. To form a subset of A, each of the n elements can either be in the
subset or not (2 ways). Therefore, there are 2n possible ways to form unique
subsets, therefore, |P(A)| = 2n.
Example 3.1.4. How many legal configurations are there in the towers of Hanoi?
Solution 3.1.4. Each of the n rings can be on one of three poles, giving us 3n
configurations. Normally we would also need to count the height of a ring relative
to other rings on the same pole, but in the case of the towers of Hanoi, the rings
sharing the same pole must be ordered in a unique fashion: from small at the top
to large at the bottom.
The sum rule is probably even more intuitive than the product rule. Suppose there
are n(A) ways to perform task A, and distinct from these, there are n(B) ways to
perform task B. Then, there are n(A) + n(B) ways to perform task A or task B.
This can generalize to multiple tasks, e.g., n(A) + n(B) + n(C) ways to perform
task A, B, or C, as long as the distinct condition holds, e.g., the ways to perform
task C are different from the ways to perform task A or B.
Example 3.1.5. To fly from Lagos to Brisbane you must fly through Istanbul or Dubai.
Solution 3.1.5. There are 5 such flights a day through Istanbul, and 3 such flights
a day through Dubai. How many different flights are there in a day that can take
you from Lagos to get to Brisbane? The answer is 5 + 3 = 8.
What is P(n, r)? To form an r-permutation from a set A of n elements, we can start
by choosing any element of A to be the first in our permutation; there are n
possibilities. The next element in the permutation can be any element of A except
the one that is already taken; there are n−1 possibilities. Continuing the argument,
the final element of the permutation will have n − (r − 1) possibilities. Applying
the product-rule, we have:
Note that 0! = 1.
Example 3.2.1.1. How many one-to-one functions are there from a set A with m
elements to a set B with n elements?
Lemma 3.2. (Pascal’s Identity). If 0 < k ≤ n, then C(n + 1, k) = C(n, k − 1) + C(n, k).
Proof. Here is another way to choose k elements from n + 1 total element. Either the n +
1st element is chosen or not:
Pascal’s identity, along with the initial conditions C(n, 0) = C(n, n) = 1, gives a
recursive way of computing the binomial coefficients C(n, k). The recursion table
is often written as a triangle, called Pascal’s Triangle; as shown in Figure 3.1.
Lemma 3 n.
Proof. Let us once again count the number of possible subsets of a set of n
elements. We have already seen by induction and by the product rule that there are
2n such subsets; this is the RHS.
Figure 3.1. Pascal’s triangle contains the binomial coefficients C(n, k) ordered as
shown in the figure. Each entry in the figure is the sum of the two entries on top
of it (except the entries on the side which are always 1).
Proof. Simply write 2n = (1+1)n and expand using the binomial theorem.
Corollary 3.2. .
Proof. Expand 0 = 0 = (1 − 1) using the binomial theorem:
n n
(a + b) 3 = a3 + 3a2b + 3ab2 + b3
Thinking of (a + b)3 as
= a3 + 3a2b + 3ab2 + b3
we note that the term 3ab2, for example, arises from the two terms ab2 and 2ab2 ;
again this is the link with the way 3 is generated in Pascal’s triangle - by adding
the 1 and 2 in the previous row.
Solution 3.4.1. Let A be the set of multiples of 2 and B be the set of multiples of 5. Then
|A| = 50, |B| = 20, and |A ∩ B| = 10 (since this is the number of multiples of 10). By the
inclusion-exclusion principle, we have 50 + 20 − 10 = 60 multiples of either 2 or 5.
What if there are more tasks? For three sets, we can still gleam from the Venn diagram
that
|X ∪ Y ∪ Z| = |X| + |Y | + |Z| − |X ∩ Y | − |X ∩ Z| − |Y ∩ Z| + |X ∩ Y ∩ Z|
More generally,
4.0 Conclusion
Specially, you have learned about counting. You have also learned how to carry out
counting using some special techniques and principles.
5.0 Summary
In this unit, you have learnt how to use Pascal’s triangle to expand a binominal
expression. You have also been taught how to identify and apply inclusion-
exclusion and pigeonhole principle.
6.0 Tutor-Marked Assignment
1. How many positive divisors does 2000 = 2453 have?
2. Six friends Adam, Brian, Chris, Dan, Elvis and Frank want to go see a movie. If there
are only six seats available, how many ways can we seat these friends
3. Expand the following:
4. Find the minimum number of students in a class such that three of them are born in
the same month.
5. Show that from any three integers, one can always choose two, so that a3b – ab3 is
divisible by 10.
7.0 References/Further Reading
Asimow, L and Maxwell, M (2010). Probability and Statistics with Applications.
A problem solving text. ACTEX publications Inc. Winsted,
Conecticut. ISBN: 978-1-56698-721-9
Coolman, R. (2015). Properties of Pascal’s triangle. Published 17 June 2015.
Fraleigh, J. B. (1982). A First Course in Abstract Algebra, 3rd ed., Addison-Wesley.
Gallian, J. A. (1998. Contemporary Abstract Algebra, 4th edition, Houghton-Mifflin.
Kiltinen, J.O. (2004). Parity Theorem for Permutations - Convergence (December 2004)