Discrete Maths Lecture Note (Chapter 1-3)
Discrete Maths Lecture Note (Chapter 1-3)
Discrete Maths Lecture Note (Chapter 1-3)
Chapter One
1. Elementary Counting Principles
1.1 Basic counting principles
1. The sum rule
If the first task can be done in n1 ways the second task in n2 ways and if the tasks can not be
done in the same time, then there are n1 + n2 ways to do either task.
Example: - A student can choose a mathematics project from a set theory (23 topics) and a
number theory (29 topics)how many possible projects are there to choose from?
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
= n1 + n2 +… + nk
An equivalent form of sum rule using set theory terminology is given let A1, A2, …., Ak be any
finite pair wise disjoint sets, then
| | =
Example:-one can reach city B from city A by bus, train, air or by road(feet) suppose that there
are 2 ways by bus, 3 ways by train,4 ways by air and 5 ways by road(feet) then, How many ways
are there to reach from city A to B?
2. The product rule
Suppose that a procedure can be broken down into two tasks if there are n1 ways to do the first
task n2 ways to do the second task after the first task can be done then there are n1 x n2 ways to
do the procedure.
1
Example: The chair of a library is to be labeled with a capital letter and a positive integer not
exceeding 100. What is the largest number of chair that can be labeled differently?
Solution: The procedure of labeling a chair consists of two tasks, namely, assigning to the seat
one of the 26 uppercase English letters, and then assigning to it one of the 100 possible integers.
The product rule shows that there are 26 · 100 = 2600 different ways that a chair can be labeled.
Therefore, the largest number of chairs that can be labeled differently is 2600
Exercise: There are 32 microcomputers in a computer center each micro computer has 24 ports.
How many different ports to a microcomputer in the center are there?
Generalized product rule: Assume that a task can be decomposed in to r say T 1, T2, ….Tr and
there are n1 ways for T1 to occur, n2 ways for T2 to occur.... nr ways for Tr to occur the total
number of ways for the task to occur is given by n1 x n2 x …….x nr =
Exercise: There are 2 ways to travel from city A to city B, 5 ways from city B to C and 3 ways
from city C to D. what is the number of ways to go from city A to D via B and C?
Example: In version of the computer language BASIC the name of the variable is a string of one
or two alpha numeric character more over the variable name must begin with a letter and must be
different from the 5 strings of two characters that are reserved for programming use. how many
variable name are there in the version of BASIC?
Example: Each users in a computer system has a password which is 6 to 8 characters long where
each character is an upper case letter or a digit. Each password must contain at least one digit.
how many possible passwords are there?
Example:- How many integers are there between 0 and 1000 that have one or more 6's as
digits?
Exercise:- How many odd integers are there between 100 and 1000.
2
1.2 The inclusion -Exclusion principle
when two tasks A and B can be done at the same time we cannot use sum rule to count the
number of ways to do one of the tasks, so the number of ways to do one of the two tasks obtained
by adding the number of ways to do each tasks and then subtract the number of ways to do both
tasks.
Example: How many bit string of length 8 either starts with the 1's or ends with the two zeros?
Example: A discrete mathematics class contains 25 students majoring in CS, 13 in maths and 8
in both. How many students are in this class if every student is majoring in maths, CS or both?
Ayele B E
Example: A total of 1232 students have taken a course in Spanish 879 have taken a course in
French and 114 have taken a course in Russian. Further 103 have taken course both in Spanish
and French 23 have taken course both in Spanish and Russian and 14 have taken course both in
Russian and French. if 2093 have taken at least one of Spanish, French and Russian, how many
students have taken a course in all the languages?
Example: Let u be the set of positive integers not exceeding 1000 then | U| = 1000 find |S| where
S is the set of such integers which are not divisible by 3,5 or 7?
The Three diagram
we use a branch to represent each possible choice. we represent the possible outcomes by leaves
(which are the end point of branches not having other branches starting on them.)
Example: how many bit strings of length four which doesn't have two consecutive 1's?
If n pigeonholes are occupied by n + 1 or more pigeons then atleast one pigeonhole is occupied
by more than one pigeon.
Example: Suppose a department contains 14 professors then two of the professors (pigeon)
where born in the same month(pigeonholes).
Example: Find the minimum number of elements that one need to take from the set
S = {1, 2, 3,…9 } to be sure that two of the number add up to 10?
If N objects are placed in to k boxes, then there is at least one box containing at least [N / K]
Objects.
3
Note: Generalized pigeonhole principle:-if n pigeonholes are Occupied by k + 1 or more
pigeons, where k at least one pigeonhole is occupies by k + 1 or more pigeons.
Example: Find the minimum number of students in a class to be sure that three of them are born
in the same month?
Example:
1. Find the least number of cables required to connect eight computers to four printers to
guarantee that for every choice of four of the eight computers, these four computers can directly
access four different printers.
2. Find the minimum number of students needed to guarantee that 5 of them belong to the same
class (freshman, sophomore, junior, senior)?
Exercise:
1. Find the minimum number of elements that one need to take from the set S = {1, 2, 3, ….. 8}
to be sure that two of the number add up to 9?
2.Find the least number of cables required to connect 100 computers to 20 printers to guarantee
that for every choice of 20 of the 100 computers, these 20 computers can directly access 20
different printers.
A
1.4 Permutations and Combinations
1.4.1 Permutation
Permutation of a set of distinct objects is an ordered arrangement of these objects. An ordered
arrangement of r-objects of a set is called an r-permutation
Example: Let S = {1, 2, 3}. The arrangement {3, 1, 2 } is a 3-permutation of S. The arrangement
{3, 2} is a 2-permutation of S.
Proof:
There are n , ways to choose the first element
There are (n -1), ways to choose the second element
...
There are (n - r + 1), ways to choose the element.
so by PR there are n x(n – 1) x …x (n - r + 1) r-permutation.
4
Example:
1. Suppose there are 8 runners in a race. how many different ways are there to award the gold,
silver and bronze medal if all possible outcomes of the race can occur?
2. How many ways can a president, vice-president and secretary be selected from a committee of
seven people?
3. Suppose that a sales women has to visit eight different cities. she must begin her trip in a
specific city, but she can visit the other in any order she wishes. How many possible orders can
the sales women use when visiting these cities?
Example: Find the number of seven letter word that can be formed using the letter of the word
"BENZENE"
Ordered sample:
Choose one element after another r-times we call the choice an ordered sample of size r.
1. Sample with replacement:
n x n x …. x n = , choose r objects from n objects. When repetition allowed.
2. Sample without replacement:
= choose r objects from n objects when repetition allowed.
Example: Three cards are chosen one after the other from 52-card deck. Find the number m of
ways this can be done.
a) With replacement
b) Without replacement
1.4.2 Combination:
An r-combination of elements of a set is an unordered collection of r-elements from a set.
Example: C(4; 2) = 6 since 2-combination of {a, b, c, d } are the six subsets {a, b } , {a, c} ,
{a, d }, {b , c}, {b, d}, {c, d}
Proof : ( Exercise)
5
Corollary: let n, r with r n , then C(n, r ) = C(n, n - r ).
Theorem: There are C(n+r-1, r) r-combinations from a set with n-elements when repetitions of
elements is allowed.
Example:
1.Suppose that a cookie shop has four different kinds of cookies. How many different ways can
six cookies be chosen? Assume that only the type of cookies and not the individual cookies or
the order in which they are chosen matters.
2. How many solutions does the equation x1 + x2 + x3 = 11 have where x1, x2 and x3 are non-
negative integers?
3. How many ways can you solve k1 + k2 + k3 + k4 = 18 provided that k1, k2, k3, k4 are integers
and k1, k2 0, k3 3k4 2?
r - combination no
r - permutation yes
6
Note:
1. Distributing n identical objects in to k distinct sets is
C(n + k – 1, k - 1)
2. The number of ways n-distinct elements can be assigned to n cells so that exactly one cell is
empty is n! C(n, 2)
Example: A data set contains 500 observations. Analysis of the data is carried out by three
programs that together process the 500 observations such that each program processes at least
100 observations. If the partition of the 500 observations for use by the three programs is done
by arbitrarily choosing the observation for each program. In how many ways can the data be
processed?
Example: The number of ways 5 elements a, b, c, d, e can be assigned to three cells so that
exactly 1 cell is empty.
1 1
1 2 1
1 3 3 1
1 4 6 4 1
….. …..
Theorem:
Let n be a positive integer, then =
Proof:
A set with n elements has a total of subsets each subsets have either 0,1,2,...,n elements in it
there are C(n,0) subsets with zero element
C (n,1) subsets with zero element
C (n, 2) subsets with zero element
...
C (n, n) subsets with zero element
Since the elements are disjoint by sum rule =
7
Theorem: Vandermonde’s identity: let m, n and r be non negative integers with r
not exceeding either m or n. Then
= since ,
Note:
The binomial theorem gives the coefficients of the expansion of power of binomial expression i.e
x+y
= .
Where k = 0,1,...,n
= .
8
Chapter two
2: Elementary probability Theory
2.1 sample space and events
Some basic terminologies
An experiment :- is any process or an activity that generates a set of
possible outcomes.
A sample space(S):- is a set that contains all possible outcomes of an
experiment .
An Event(E) :- is any subset of a sample space.
p(E) = = =
Example2: A bag contains four blue balls and five red balls. What is the
probability that a ball chosen at random from the bag is blue?
Solution: There are nine possible outcomes, and four of these possible outcomes
produce a blue ball. That is p(E) = = . Hence, the probability that a blue
ball is chosen is .
We can use counting techniques to find the probability of events derived from
other events.
Theorem : Let E be an event in a sample space S. The probability of the event
= S − E, the complementary event of E, is given by p( ) = 1 − p(E).
Proof: To find the probability of the event = S – E , note that | | = |S| − |E|.
Hence p( ) = = = 1 − p(E)
9
Example: A fair die is rolled. What is the probability that a face comes up is odd?
Solution: let S be the set of all possible outcomes. That is S = { 1, 2, 3, 4, 5, 6}
And let E be the set of the event that the number comes up is odd .That is
E = {1,3,5}. Then is the event that the number comes up is Even.
Thus, p( ) = = = 1 − p(E) = =
Hence, the probability that the face comes up odd is 0.5.
Hence P(E1 = =
Example: What is the probability that a positive integer selected at random from
the set of positive integers not exceeding 100 is divisible by either 2 or 5?
(exercise)
i. 0 for i = 1,2,..,n
ii.
10
Theorem: If E1,E2,E3,….is a sequence of pairwise disjoint events in a sample
space S, then
P i = 1, 2, ……
Definition: Let E and F be two events with P(F) > 0 . The conditional probability
of E given F is denoted by P(E F), is defined as
P(E F) = .
Example: What is the conditional probability that a family with two children has
two boys, given they have at least one boy?
Solution: Let E be the event that a family with two children has two boys, and let
F be the event that a family with two children has at least one boy. It follows that
E = {BB}, F = {BB, BG, GB}, and E ∩ F = {BB}. Because the four possibilities
are equally likely, it follows that p(F) = 3/4 and p(E ∩ F) = 1/4.We conclude that
P(E F) = =
Exercise: A bit string of length four is generated at random so that each of the 16
bit strings of length four is equally likely. What is the probability that it contains at
least two consecutive 0s, given that its first bit is a 0?
Definition: The events E and F are independent if and only if p(E ∩ F) = p(E)p(F).
Example: Are the events E, that a family with three children has children of both
sexes, and F, that this family has at most one boy, independent? Assume that the
eight ways a family can have three children are equally likely.
Solution: By assumption, each of the eight ways a family can have three children,
BBB, BBG, BGB, BGG, GBB, GBG, GGB, and GGG, has a probability of 1/8.
Because E = {BBG, BGB, BGG, GBB, GBG, GGB}, F = {BGG, GBG, GGB,
GGG}, and E ∩ F = {BGG, GBG, GGB}, it follows that p(E) = 6/8 = 3/4,
11
p(F) = 4/8 = 1/2, and
p(E ∩ F) = . Because P(E) P(F) = . = . It follows that
p(E ∩ F) = p(E)p(F), so E and F are independent.
Definition: The events E1, E2, . . . , En are pairwise independent if and only if
p(Ei ∩ Ej ) = p(Ei) p(Ej ) for all pairs of integers i and j with 1 ≤ i < j ≤ n. These
events are mutually independent if p(Ei1 ∩ Ei2 ∩ ・・ ∩ Eim) = p(Ei1)p(Ei2 ) ・
・ p(Eim) whenever ij, j = 1, 2, . . . , m, are integers with 1 ≤ i1 < i2 < ・ ・ ・ <
im ≤ n and m ≥ 2.
Example1 : Suppose that a coin is thrown three times. Let X(t) be the random
variable that equals the number of heads that appear when t is the outcome. Then
X(t) takes on the following values:
X(HHH) = 3,
X(HHT ) = X(HTH ) = X(THH ) = 2,
X(TTH ) = X(THT ) = X(HTT ) = 1,
X(TTT ) = 0.
Example2 : Each of the eight possible outcomes when a fair coin is thrown three
times has probability 1/8. So, the distribution of the random variable X(t) in
Example 1 is determined by the probabilities P(X = 3) = 1/8, P(X = 2) = 3/8,
12
P(X = 1) = 3/8, and P(X = 0) = 1/8. Consequently, the distribution of X(t) in
Example 1 is the set of pairs (3, 1/8), (2, 3/8), (1, 3/8), and ( 0, 1/8).
Definition: The expected value, also called the expectation or mean, of the random
variable X on the sample space S is equal to
Mean = E(X) =
Expected Value of a Die : Let X be the number that comes up when a fair die is
rolled. What is the expected value of X?
Solution: The random variable X takes the values 1, 2, 3, 4, 5, or 6, each with
probability 1/6. It follows that
2. A fair coin is thrown three times. Let S be the sample space of the eight possible
outcomes, and let X be the random variable that assigns to an outcome the number
of heads in this outcome. What is the expected value of X?
.Solution : when a coin is thrown three times. Because the coin is fair and the flips
are independent, the probability of each outcome is 1/8. Consequently,
13
Chapter three
3. Recurrence Relations
3.1 Definition and examples
Definition: A recurrence relation for the sequence {an} is an equation that expresses an in-terms
of one or more of the previous terms of the sequence a0, a1, a2, … an-1 for all n Z with
n n0 where n0 .
A sequence is the solution of the recurrence relation if its terms satisfy the recurrence relation.
Example: Let {an} be a sequence that satisfy the recurrence relation = for
n = 2, 3, 4, … and suppose that a0 = 3 and a1 = 5. what are the values of a2 and a3?
Example: A computer system considers a string of decimal digits a valid codeword if it contains
an even number of 0 as digits. Find the formula for a valid n-digit cod words?
Note:
Linear:-there are no power or product of
Constant coefficient:- C1, C2, C3, …..Ck doesn't depends on n.
if f (n) = 0 the recurrence relation is homogeneous otherwise non-homogeneous.
14
Example:
A sequence: is the solution of the recurrence relation if its terms satisfy the recurrence relation
Example: Determine whether the sequence {a n} is a solution of the recurrence relation
for n = 2, 3, 4, …. For all n
a. 3n
b. =
c. =5R
………(1)
……..(2)
equation (2) is called the Characteristics equation of the recurrence relation in equation (1).
the solution of the characteristics equation is called Characteristics root of the recurrence
relation.
Theorem : Let C1 ,C2, ..., Ck be real numbers, suppose that the characteristics equation
has t-distinct roots r1, r2,...,rt with multiplicity
m1 + m2 +… + mt = k. Then the sequence {an} is a solution of the recurrence relation
if and only if
15
for n = 0,1,2, … where are constants for 1
and 0
Example: suppose the characteristics roots of the recurrence relation are 2, 2, 2, 5, 5, 9. what
is the form of the general solution?
Example :
16
Theorem 5: Suppose that {an} satisfies the linear non-homogeneous recurrence relation
+ f (n) and
f(n) = ) where
when s is not the root of the characteristics equation of the associated homogeneous
recurrence relation then the particular solution is (
)
a. f(n) =
b. f(n) =
c. f(n) =
d. f(n) =
b =
Example: Let be the sum of the first n-positive integers, so that which is the
same as
b. =
17
3.4 Solution of Recurrence Relation Using Generation function
Definition: Let S = { a0, a1, a2 , ….} be an infinite sequence of real numbers, then the
generating function G(x) of S is the power series G(x) = .
Example:
S = { 1, 1, 1, … } =
S = { 0, 1, 2, …. }
S = { 1, 1, 1, … } = 1+x+x2
For solving Recurrence relation: We use the following generating function if G(x) =
G(x) = =
18
19