Discrete Lecture - Notes
Discrete Lecture - Notes
This chapter develops some techniques for determining, without direct enumeration, the
number of possible outcomes of a particular event or the number of elements in a set. Such
sophisticated counting is sometimes called combinatorial analysis. It includes the study of
permutations and combinations
By Mesfin M, AAU
1.1 Basic counting principles 2
Solution. The student can choose a project by selecting a project from the first list, the
second list, or the third list. Because no project is on more than one list, by the sum rule
there are 23 + 15 + 19 = 57 ways to choose a project.
Example 1.1.3. Suppose E is the event of selecting a prime number less than 10 and F is
the event of selecting an even number less than 10. Then E can happen in 4 ways, and F can
happen in 4 ways. But, because 2 is even and prime, E or F can happen in only 4+4-1=7
ways.
Generalized Addition Principle
If A1 , A2 , A3 , ..., An are pairwise disjoint sets, then | ni=1 Ai | = ni=1 |Ai |.
S P
Example 1.1.4. One can reach city B from city A by bus, car, foot or train. Suppose that
there are 3 ways by train, 2 ways by bus, 4 ways on foot and 5 ways by car. What is the
total number of ways going from city A to city B?
Solution: By (AP), there are a total of 2+3+4+5=14 ways to go from city A to city B.
Example 1.1.5. There are four different blood types: O, A, B, and AB. If the Red Cross
collects blood donations from 10 people of type O, 15 type A, 12 type B, and 8 type AB, then
it has collected blood from a total of 10 + 15 + 12 + 8 = 45 people.
In other words, if a task can be broken down into first and second stage, and if there
are m possible ways of performing in the first stage and n possible ways of performing the
second stage, then the possibilities that the task can be carried out is m × n. In other
words,if procedure can be break down in to a sequence of two tasks, if there are n ways to do
the first and there m ways to do the second task, then there are nm ways to do the procedure.
Example 1.1.6. A book shelf holds 6 different English books, 8 different mathematics books,
and 10 different chemistry books, there are
i) 6 × 8 × 10 = 480 ways of selecting 3 books, in each subject;
ii) An English and a mathematics books can be selected in 6 × 8 = 48 ways, an English and a
chemistry books, in 6 × 10 = 60 ways, a mathematics and a chemistry books, in 8 × 10 = 80
ways. Thus there are 48 + 60 + 80 = 188 ways of selecting 2 books in 2 subjects.
In general, suppose that an event E can be decomposed in to r ordered events E1 , E2 , ..., Er
and that there are
n1 Ways for the event E1 to occur
n2 Ways for the event E2 to occur
n3 Ways for the event E3 to occur
By Mesfin M, AAU
1.1 Basic counting principles 3
.
.
.
nr Ways for the event Er to occur
Qr the total number of ways for the event E to occur is given by n1 × n2 × n3 × ... × nr
Then
= i=1 ni .
Example 1.1.7. To reach city D from city A, one has to pass through city B and then
through city C. If there are 2 ways to travel from city A to city B, 5 ways to travel from city
B to city C and 3 ways from city C to city D, what is the number of ways to go from city A
to city D via city B and city C.
Solution. By multiplication principle, the number of ways is 2 ∗ 5 ∗ 3 = 30.
Example 1.1.8. There are five different mathematics books, six different chemistry books,
and eight different physics books. How many ways are there to pick an (unordered) pair of
two books not both in the same subject?
Solution. If one mathematics and one chemistry book are chosen, the multiplication prin-
ciple says that the selection can be done in 5 × 6 = 30 ways; if one mathematics and one
physics book, 5 × 8 = 40 ways; and if one chemistry and one physics book, 6 × 8 = 48
ways. These three types of selections are disjoint, and so by the addition principle there are
30 + 40 + 48 = 118 ways in all.
Example 1.1.9. The digits 0, 1, 2, 3, and 4 are to be used in 4 digit identification card.
How many different cards are possible if
a) Repetitions are permitted?
b) Repetitions are not permitted?
Solution. There are four steps
i. Selecting the 1st digit, this can be made in 5 ways.
ii. Selecting the 2nd digit, this can be made in 4 ways.
iii. Selecting the 3rd digit, this can be made in 3 ways.
iv. Selecting the 4th digit, this can be made in 2 ways.
By multiplication principle, 5*4*3*2 120 different cards are possible.
Exercise
Give your brief answer for the following questions.
1. Find the number of positive divisors of 600, inclusive 1 and 600 itself. (Ans=24)
2. How many two-digit numbers have distinct and non-zero digits? (Ans=72)
3. Each user on a computer system has a password, which is six to eight characters long,
where each character is an uppercase letter or a digit. Each password must contain at least
one digit. How many possible passwords are there?
By Mesfin M, AAU
1.2 Permutations and Combinations 4
3. The number of permutations of n objects in which k1 are alike, k2 are alike, ...,kn are
alike is given by:
n!
P (n; k1 , k2 , ..., kn ) =
k1 ! × k2 ! × ... × kn !
Note that: The third rule of permutation is called Permutation with repetitions.
Example 1.2.2. Find the number of even integers between 20,000 and 70,000 in which no
digit is repeated.
Solution. Let abcde be a required even integer. The first digit a can be chosen from
{2, 3, 4, 5, 6} and the fifth digit e can be chosen from {0, 2, 4, 6, 8}. Since {2, 3, 4, 5, 6} ∩
{0, 2, 4, 6, 8} = {2, 4, 6}, we divide the problem in to two disjoint cases.
Case I: a∈ {2, 4, 6}, so a has 3 choices, e has 4 choices and bcd has P (10 − 2, 3) = P (8, 3)
By Mesfin M, AAU
1.2 Permutations and Combinations 5
By Mesfin M, AAU
1.2 Permutations and Combinations 6
Solution. If we label the persons A, B, C, D, E, we see that the five linear permutations
are identical when thought of as circular permutations. This is so because two arrangements
of people around table are considered to form the same circular permutation if one can be
obtained from the other by rotating everybody around the circle by the same amount and
in the same direction. This is the case, for example, if everybody moves one place to his
right. Hence we can get at the number of circular permutations by relating them to the linear
permutations: each circular permutation corresponds to five linear permutations, so there
are only 51 as many circular permutations as there are linear permutations. But there are 5!
linear permutations of five objects, and hence the answer to the question is
1
(5!) = 4! = 24.
5
Hence number of r-circular permutation of a set A with n objects is
P (n, r) n!
Q(n, r) = =
r r(n − r)!
Example 1.2.6. In how many ways can 5 boys and 3 girls be seated around a table if
i. There is no restriction?
By Mesfin M, AAU
1.2 Permutations and Combinations 7
1.2.3 Combinations
A selection of objects with out regard to order is called combination. , i.e. a combination of
a set of objects is an unordered selection of the objects. Thus, an r-combination is simply a
subset of the set with r elements(r-subsets).
Note that:Permutation is an ordered arrangement of objects and Combination is a selection
without regard to order.
Example 1.2.7. Given the letters A, B, C, and D list the permutation and combination for
selecting two letters.
Solution:
Permutation Combination
AB BA CA DA AB BC
AC BC CB DB AC BD
AD BD CD DC AD DC
Note that in permutation AB is different from BA. But in combination AB is the same
as BA.
Combination Rule
The number of combinations of r objects selected from n objects without repetition is denoted
n
by C(n, r) or r , where 0 ≤ r ≤ n and is given by the formula:
n P (n, r) n!
C(n, r) = = = .
r r! r! ∗ (n − r)!
These numbers are also called binomial coefficients. Note that: The symbol C(n, r) or nr
Example 1.2.8. In how many ways a committee of 5 people be formed from a group of 11
people consisting of 4 teachers and 7 students if:
a)There is no restriction in the selection?
b)The committee must include exactly 2 teachers?
c)Two of them are T1 and T2
d)The committee must include at least 3 teachers?
e)A particular teacher and a particular student cannot both in the committee?
Exercise
1. Consider a group of 20 people. If everyone shakes hands with everyone else, how many
handshakes take place?
By Mesfin M, AAU
1.3 The inclusion- exclusion principles 8
a) There is no restriction
3. A committee of k people is to be chosen from a set of 7 women and 4 men. How many
ways are there to form the committee if:
a) The committee has 5 people, 3 women and 2 men. (Ans 210 ways)
b) The committee can be any positive size but must have equal numbers of women and
men. (Ans 329 ways)
c) The committee has 4 people and one of them must be Mr. Abebe. (Ans 120 ways)
4. Seven friends go to a restaurant for lunch and order from the menu that has four items:
fish, meat, vegetable or pasta. How many different orders are there? (Ans.=120)
5. How many positive integers less than 1000,000 have the sum of their digits equals to 9?
14
(Ans 9 )
Theorem 1. Let U be a finite set. Suppose A and B are two subsets of U . Then
By Mesfin M, AAU
1.3 The inclusion- exclusion principles 9
A generalization of this to three subsets A, B and C is also well known. To get a re-
sult that generalizes Theorem 1 for n subsets A1 , A2 , . . . , An , we need the following notations:
S1 = ni=1 |Ai |,
P P P
S2 = 1≤i<j≤n |Ai ∩ Aj |, S3 = 1≤i<j<k≤n |Ai ∩ Aj ∩ Ak |,
Sn = |A1 ∩ A2 ∩ A3 ∩ · · · ∩ An |
With the notations as defined above, we have the following theorem, called the inclusion-
exclusion principle.
|AC C C n
1 ∩ A2 ∩ · · · ∩ An | = |U | − S1 + S2 − S3 + · · · + (−1) Sn = |U | − |A1 ∪ A2 ∪ · · · ∪ An |.
Example 1.3.1. How many bit strings of length eight either start with a 1 bit or end with
two bits 00?
Solution. Let A be set of bit strings of length eight that start with 1 and B be set of bit
strings of length eight that end with 00. Then A ∩ B is set of bit strings of length eight that
start with 1 and end with 00. This implies that,
|A| = 27 , |B| = 26 and |A ∩ B| = 25 . By Inclusion-Exclusion principle,
|A ∪ B| = |A| + |B| − |A ∩ B|= 27 + 26 − 25 = 160.
Hence, there are 160 bit strings of length eight that start with 1 or end with 00.
By Mesfin M, AAU
1.4 The Pigeonhole Principle 10
Excersise
Find the number of integers between 1 and 1000, inclusive, which are divisible by none of 5,
6 or 8.
We will illustrate the usefulness of the pigeonhole principle. We first show that it can be
used to prove a useful corollary about functions.
Corollary 1. A function f from a set with k + 1 or more elements to a set with k elements
is not one-to-one.
Proof. Suppose that for each element y in the codomain of f we have a box that contains
all elements x of the domain of f such that f (x) = y. Because the domain contains k + 1 or
more elements and the codomain contains only k elements, the pigeonhole principle tells us
that one of these boxes contains two or more elements x of the domain. This means that f
cannot be one-to-one.
Examples
1. Among any group of 367 people, there must be at least two with the same birthday,
because there are only 366 possible birthdays.
2. How many students must be in a class to guarantee that at least two students receive the
same score on the final exam, if the exam is graded on a scale from 0 to 100 points?
Solution. There are 101 possible scores on the final. The pigeonhole principle shows that
among any 102 students there must be at least 2 students with the same score.
By Mesfin M, AAU
1.5 The Binomial Theorem 11
Solution. The minimum number of students needed to ensure that at least six students
receive the same grade is the smallest integer N such that ⌈ N5 ⌉ = 6. The smallest such
integer is N = 5 × 5 + 1 = 26. If you have only 25 students, it is possible for there to be five
who have received each grade so that no six students have received the same grade. Thus, 26
is the minimum number of students needed to ensure that at least six students will receive
the same grade.
Solution. Let z = y 2 , then apply binomial theorem to (2x + z)5 , and find the coefficient
ofx3 z 2 . The term involving x3 z 2 is 52 (2x)3 z 2 . Hence the coefficient of x3 z 2 = x3 y 4 is
5 3
2
2 = 80.
Exercise
1. Expand (2xy − y3 )5 using binomial theorem.
2. What is the coefficient of x3 y 194 in the expansion of (2x + y 2 )100 ?
3. Find the constant
Pn term in the expansion of (2x2 − x1 )12 . (Ans 7920)
Show that k=0 nk 2k = 3n
4.
By Mesfin M, AAU
1.5 The Binomial Theorem 12
1.5.2 Multinomial
We have seen the value of binomial coefficients in expanding a power of a binomial. It is
natural to ask whether a similar family of coefficients might prove helpful when we wish to
expand a power of a ”trinomial” (x + y + z) or in general a ”multinomial” (x1 + x2 + ... + xm ).
By Mesfin M, AAU
1.5 The Binomial Theorem 13
Examples:
6!
1. The coefficient of x21 x2 x23 x4 in the expansion of (x1 + x2 + x3 + x4 )6 is 2!2!1!1!
= 180.
6!
2. The coefficient of x31 x2 x23 in the expansion of (2x1 − 3x2 + 5x3 )6 equals 3!1!2! 23 (−3)52 =
−36000.
Exercise
1. Prove the following using the idea of Pascal identity
i. n0 − n1 + n2 − n3 + · · · + (−1)n nn = 0
By Mesfin M, AAU
1.5 The Binomial Theorem 14
Worksheet I
1. a) How many permutations of size 3 can one produce with the letters p,r,m and n? List
them.
b) List all combinations of size 3 that one produce with the letters p,r,m,t and n?
2. m boys and n girls are to be arranged in a row, where m, n ∈ N with n ≥ m. Find the
number of ways this can be done in each of the following cases:
a) There are no restrictions;
d) Vowels are not used and the numbers begin with odd digits and end in even digits?
5. Find the value(s) of n in each of the following
a) P (n, 2) = 90 c) P (n, 3) = 3P (n, 2)
7. Determine x if 50 50 r
P 100
r=0 r 8 = x
8. Find the coefficient of x y in the expansion of (2x − 3y)6 .
4 2
9. Determine the number of positive integers whose decimal expansion contains exactly 4
digits, doesn’t contain equal digits, and doesn’t contain the digit 3.
10. How many integers between 1 and 1000 have all their digits different and don’t contain
the digit 5 in their decimal expansion?
11. How many bit strings of length 10 contain at least three 1s and at least three 0s?
12. Find the number of positive integers less than 601 that are not divisible by 3 or 5 or 7.
By Mesfin M, AAU
1.5 The Binomial Theorem 15
13. Find the number of even integers between 10,000 and 60,000 in which no digit is re-
peated.
14. Show that among any n + 1 positive integers not exceeding 2n there must be an integer
that divides one of the other integers.
15. Assume that in a group of six people, each pair of individuals consists of two friends or
two enemies. Show that there are either three mutual friends or three mutual enemies in the
group.
16. How many positive integers less than 1,000,000 have exactly one digit equal to 9 and
have a sum of digits equal to 13?
By Mesfin M, AAU
Chapter 2
Recurrence Relation
A sequence can be defined by giving a general formula for its nth term or by writing few of
its terms. An alternative approach is to write the sequence by finding a relationship among
its terms. Such a relationship is called a recurrence relation or sometimes called difference
equation.
Definition 1. A recurrence relation for the sequence {an } is an equation that relates an
interms of one or more of the previous terms of the sequence, namely a0 , a1 , ..., an−1 for all
integers n >= n0 , where n0 is a non negative integer. The values a0 , a1 , ..., an−1 are explicitly
given values and are not defined by recursive formula. They are called initial conditions or
boundary conditions of the recurrence relation.
Definition 2. Initial condition: the information about the beginning of the sequence.
with f (n) is a function and c1 , c2 , ..., ck are constants. Then this Recurrence Relation is
called
i. Homogeneous Recurrence Relation of degree k if f (n) = 0.
By Mesfin M, AAU
2.2 Recurrence Relation Models 17
1. an − 3an−1 + 2an−2 = 0
4. an − 3an−1 + 2an−2 + 5 = 0
5. an − 3an−1 + 2an−2 = 2n − 4
i. rabbit begin to produce young two months after their own birth;
By Mesfin M, AAU
2.2 Recurrence Relation Models 18
i. After reaching the age of two months, each pair produces a mixed pair, (one male, one
female), and then another mixed pair each month there after; and
i. no rabbit die
Solution. Let hn denote the number of moves needed to solve the Tower of Hanoi problem
with n disks. If there is only one disk, we simply move it to the second peg in one way. Thus
h1 = 1. If we have n > 1, we can transfer n − 1 disks to the second peg in hn−1 moves.
During the moves, the largest disk at the bottom of the first peg stays fixed.Then we use one
move to transfer the largest disk to the second peg. We can now move again n − 1 disks on
the second peg to the third peg using hn−1 moves. Therefore,
hn = 2hn−1 + 1, n > 1
By Mesfin M, AAU
2.3 Solving Recurrence Relations 19
We call this equation the characteristic equation of the recurrence relation. The roots of the
characteristic equation are called characteristic roots.
Example 2.3.1. Solve the following recurrence relations with the given initial values.
1. an = 2an−1 + 3an−2 , with initial conditions a0 = 0, and a1 = 8.
2. an = 2an−1 + an−2 − 2a−3 (n ≥ 3), with initial values a0 = 1, a1 = 2 and a2 = 0.
By Mesfin M, AAU
2.3 Solving Recurrence Relations 20
c1 + c2 + c3 = 1,
c1 − c2 + 2c3 = 2,
c1 + c2 + 4c3 = 0
an = (c11 +nc12 +...+n(m1 −1) c1m1 )r1n +(c21 +nc22 +...+n(m2 −1) c2m2 )r2n +...(ct1 +nct2 +...+n(mt −1) ctmt )rtn .
for n = 0, 1, 2, ..., where ci,j are constant is the general form of the solutions for the HRR
an = q1 an−1 + q2 an−2 + ... + qk an−k .
Example 2.3.2. Solve the following recurrence relation with the given initial values.
1. an = −6an−1 − 9an−2 , with initial conditions a0 = 2, and a1 = −3.
2. an = 4an−1 − 4an−2 for n ≥ 4 where a2 = 1 and a3 = 4.
3. an = 7an−1 − 15an−2 + 9an−3 for n ≥ 3 where a0 = 1, a1 = 2 and a2 = 3.
Solution. 1. The characteristic equation of this recurrence relation is x2 + 6x + 9 = 0, with
characteristic roots r1 = r2 = −3
Hence the solution of this RR must be of the form an = c1 (−3)n + c2 n(−3)n . After substi-
tuting the initial values we get, an = 2(−3)n − n(−3)n = (2 − n)(−3)n
2. The characteristic equation of this recurrence relation is x2 − 4x + 4 = 0, with character-
istic roots r1 = r2 = 2
Hence the solution of this RR must be of the form an = c1 2n + c2 n2n . After substituting the
initial values we get, an = 81 n2n = n2n−3
3. The characteristic equation of this recurrence relation is x3 − 7x2 + 15x − 9 = 0, with
characteristic roots r1 = 1, r2 = r3 = 3
Hence the solution of this RR must be of the form an = c1 1n +c2 3n +nc3 3n . After substituting
the initial values we get, an = 3n − 31 n3n = 3n−1 (3 − n).
Exercise
Solve the following recurrence relation with the given initial value.
1. an+2 − 5an+1 + 6an = 0 for n ≥ 3 where a0 = 1, a1 = −1.
2. an − 12an−1 + 48an−2 − 64an−3 = 0 for n ≥ 3 where a0 = 1, a1 = 4 and a2 = 32.
By Mesfin M, AAU
2.3 Solving Recurrence Relations 21
with f (n) is a function of n and c1 , c2 , ..., ck are constants, is called the rth order non homo-
geneous recurrence relation for the sequence an .
To solve linear non homogeneous recurrence relation:
1. Find the general solution of the homogeneous recurrence relation denoted by ahn
2. Find a particular solution for the given non homogeneous recurrence relation denoted
by apn
3. Combine the general solution of the homogenous recurrence relation and the particular
solution and determine the values of the constants arising in the general solution so
that the combined solution satisfies the initial conditions. i.e, an = ahn + anp
Note that: We find the values of the constants after we get the general solution, not only
after we get the homogeneous solution!!!
Example 2.3.3. Solve the following recurrence relation with the given initial value.
1. an = 2an−1 + 3n , (n ≥ 1) ,with initial conditions a0 = 2.
2. an − 3an−1 = 2 − 2n2 ,with initial conditions a0 = 3.
Solution. 1. Since the homogeneous recurrence relation an = 2an−1 , has only one charac-
teristic root r = 2, its general solution is ahn = c2n
The particular solution of an = 2an−1 + 3n , is in the form of apn = k3n , where k is constant.
By substituting it in the given LNHRR we get
k3n = 2k3n−1 +3n , after cancellation it reduces to, 3k = 2k +3 or equivalently, k = 3. Hence,
an = c2n + 3n+1 is a solution for each choice of the constants c. We now want to determine
c so that the initial condition a0 = 2 is satisfied. This gives c = −1 and the solution of the
problem is an = −2n + 3n+1 , (n ≥ 1).
2. First find ahn by solving an − 3an−1 = 0. The characteristic equation is x − 3 = 0, implies
x = 3 is the characteristic root. Therefore, ahn = A3n , where A is a constant.
To find apn , since f (n) = 2 − 2n2 is a polynomial of degree 2, we let apn = Bn2 + Cn + D,
where B, C and D are constants then, Bn2 +Cn+D −3(B(n−1)2 +C(n−1)+D) = 2−2n2 .
This yields by equating corresponding coefficients, we have
B − 3B = −2
C + 6B − 3C = 0
−3B + 3C − 2D = 2
By Mesfin M, AAU
2.4 System of linear Recurrence relations 22
By Mesfin M, AAU
2.4 System of linear Recurrence relations 23
By Mesfin M, AAU
2.4 System of linear Recurrence relations 24
Worksheet II
1. Find recurrence relations that are satisfied by the sequence formed from the following
functions.
n!
(a) an = 15!
(b) an = n2 − 6n + 8
2. Find a cubic polynomial whose roots are 5, −1, and 3. Then find a LHRRWCC with this
characteristic polynomial.
3. Solve the following recurrence relations by inspection.
4. Show that an = 4n , an = n4n , and an = 2.4n + 3n.4n are all solutions of the same
recurrence relation an = 8an−1 − 16an−2 .
5. Solve the following recurrence relations with the given initial values and find a10 and a15 .
b) an = an−1 + n2 , ao = 1.
c) an − an−1 − an−2 = 0, a0 = 1, a1 = 1.
d) an = 3an−1 − 2an−2 , a0 = 2, a1 = 3.
e) an = 2an−1 + 3an−2 , a0 = a1 = 1.
f) an = 3an−1 + 4an−2 , a0 = a1 = 1.
h) an = an−1 + n, a0 = 2.
i) an = 3an−1 − 4n + 32n , a1 = 8.
a) a0 = 2 and b1 = 1 b) a0 = −1 and b0 = 5.
By Mesfin M, AAU
2.4 System of linear Recurrence relations 25
7. What is the general form of the particular solution of the linear nonhomogeneous recur-
rence relation an = 6an−1 − 12an−2 + 8an−3 + F (n) if
a) F (n) = n2 ? d) F (n) = n2 2n ?
8. An employee joined a company in 1987 with a starting salary of 50, 000. Every year this
employee receives a raise of 1000 plus 5% of the salary of the previous year. Then
a) Find a recurrence relation for the salary of this employee n years after 1987.
b) Find an explicit formula for the salary of this employee n years after 1987.
9. Find a recurrence relation for the number of binary strings of length n that do not contain
the pattern 0000 and find the initial values.
10. Suppose that each year you deposit d birr into a bank account, at an annual interest
rate equal to i%. Find a recurrence relation for the amount in your account at the end of
n-years. Solve the recurrence relation.
By Mesfin M, AAU