Discrete Maths II Merged
Discrete Maths II Merged
Lecture One
Topic:
The Fundamental Counting
Principles
Introduction
Counting means determining the number of different ways of
If the problem were to determine the number of bit strings of length fifty,
I other words, if we can do task 1 in a ways and task 2 in b ways, where none of
the set of a ways is the same as any of the set of b ways (the tasks are
Example 1.3,
How many ordered pairs of integers (x, y) are there such that 0 < xy ≤ 5 ?
{ }
Solution: Let E k = ( x, y ) ∈ Ζ 2 : xy = k for k = 1, ,5. Then the desired number is
E1 + E 2 + E3 + E 4 + E5 .
We can compute each of these as follows :
E1 = {(− 1,−1), (− 1, 1), (1,−1), (1, 1)}
E 2 = {(− 2,−1), (− 2, 1)(− 1,−2), (− 1, 2), (1,−2), (1, 2), (2,−1), (2, 1)}
E3 = {(− 3,−1), (− 3, 1)(− 1,−3), (− 1, 3), (1,−3), (1, 3), (3,−1), (3, 1)}
E 4 = {(− 4,−1), (− 4, 1)(− 2,−2), (− 2, 2), (− 1,−4 ), (− 1, 4 ), (1,−4 ), (1, 4 ), (2,−2 ), (2, 2 ), (4,−1), (4, 1)}
E5 = {(− 5,−1), (− 5, 1)(− 1,−5), (− 1, 5), (1,−5), (1, 5), (5,−1), (5, 1)}
The desired number is therefore 4 + 8 + 8 + 12 + 8 = 40.
If you need to accomplish some task that takes n steps, and there are a1 ways
of accomplishing the first step, a2 ways of accomplishing the second step, etc.,
and an ways of accomplishing the n th step, then there are a1 ⋅ a 2 ⋅ ⋅ a n ways of
accomplishing the task.
Solution:
There are 1 x 1 x 1 x 2 x 2 = 4 bit strings of length five starting with three 0’s.
Using the same reasoning, there are 1 x 1 x 2 x 2 x 2 = 8 bit strings of length five
A bit string cannot both start with three 0’s and also with two 1’s, (in other words,
starting with three 0’s and starting with two 1’s are independent).
Hence, 4 + 8 = 12 bit strings of length five starting with either three 0’s or two 1’s.
Solution:
Let A be the set of strings which consist of three capital English letters followed
B be the set of strings which consist of two digits followed by four capital
English letters.
Solution:
Let P be the total number of possible passwords, and let P6, P7, and P8 denote the number of
possible passwords of length 6, 7, and 8, respectively. By the sum rule, P = P6 + P7 + P8.
To find P6 it is easier to find the number of strings of uppercase letters and digits that are six
characters long, including those with no digits, and subtract from this the number of strings
with no digits.
6
By the product rule, the number of strings of six characters is 36 , and the number of strings
with no digits is 26 6 .
366 − 26 = 1,867,866,560.
6
Hence, P6 =
Similarly, we have
P7 = 36 7 − 26 7 = 70,332,353,920 and
P8 = 368 − 268 = 2,612,282,842,880.
Consequently,
P = P6 + P7 + P8 = 2,684,483,063,360.
A B = A + B − A B
Solution:
Finding the number of applicants who majored neither in computer science nor in business, subtract the
number of students who majored either in computer science or in business (or both) from the total number
of applicants.
Let A be the set of students who majored in computer science and B the set of students who majored in
business. Then A ∪ B is the set of students who majored in computer science or business (or both), and
A ∩ B is the set of students who majored both in computer science and in business. By the subtraction rule
the number of students who majored either in computer science or in business (or both) equals
We conclude that 350 − 316 = 34 of the applicants majored neither in computer science nor in business.
Example 1.12
How many different ways are there to seat four people around a circular table, where
two seatings are considered the same when each person has the same left neighbor
or the same right neighbor?
Solution:
We arbitrarily select a seat at the table and label it seat 1.
We number the rest of the seats in numerical order, proceeding clockwise around the table.
Note that are four ways to select the person for seat 1, three ways to select the person for
seat 2, two ways to select the person for seat 3, and one way to select the person for seat 4.
Thus, there are 4! = 24 ways to order the given four people for these seats.
However, each of the four choices for seat 1 leads to the same arrangement, as we
distinguish two arrangements only when one of the people has a different immediate left or
immediate right neighbor. Because there are four ways to choose the person for seat 1, by
the division rule there are 24 ∕4 = 6 different seating arrangements of four people around the
circular table.
Emmanuel Kpeglo KNUST 4-12
The Pigeonhole Principle
If there are more items than containers, then at least one container
sex.
Theorem 1.1 (The Generalized Pigeonhole Principle).
If n objects are placed into k boxes, then there is at least one box
that contains at least ⌈n/k⌉ objects.
Proof: We will use a proof by contraposition. Assume not. Then each of the k
boxes contains no more than ⌈n/k⌉−1 objects. Notice that ⌈n/k⌉ < n/k + 1 (convince
yourself that this is always true). Thus, the total number of objects in the k boxes
is at most k (⌈n/k⌉ − 1) < k(n/k + 1 − 1) = n,
class to be sure that at least six will receive the same grade, if there are five
possible grades, A, B, C, D, and F?
Solution:
Remember n = k(r − 1) + 1, is the smallest integer satisfying the inequality ⌈n/k⌉ ≥ r.
The minimum number of students needed to ensure that at least six students
receive the same grade is the smallest integer n such that ⌈n/5⌉ = 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
socks. What is the smallest number of socks you must take from
the drawer in order to be guaranteed that you have a matching
pair?
Solution:
Solution:
question, because we want to make sure that there are three hearts, not
just three cards of one suit.
Note that in the worst case, we can select all the clubs, diamonds, and
The next three cards will be all hearts, so we may need to select 42
2. A multiple choice test contains 10 questions. There are four possible answers for
each question.
(a) How many ways can a student complete the test if every question must be
answered?
(b) How many ways can a student complete the test if questions can be left
unanswered?
3. How many license plates can be made using either three digits followed by three
uppercase English letters or three uppercase English letters followed by three
digits?
6. A bowl contains 10 red balls and 10 blue balls. A woman selects balls at random
without looking at them.
(a) How many balls must she select to be sure of having at least three balls of the
same color?
7. There are six professors teaching the introductory discrete mathematics class at a
university. The same final exam is given by all six professors. If the lowest
possible score on the final is 0 and the highest possible score is 100, how many
students must there be to guarantee that there are two students with the same
professor who earned the same final examination score?
Emmanuel Kpeglo-KNUST 4-20
CSM 166
Lecture TWO
Topic:
The Fundamental Counting
Principles
Permutations and Combinations
A permutation of a set of distinct objects is an ordered
a set.
permutation.
Solution 2.1:
Since the first city is fixed, the remaining seven can be ordered
20! 20 ⋅ 19 ⋅ 18 ⋅ 17 ⋅ 16!
P(20,4) = = = 116280
(20 − 4)! 16!
22!
C (22,11) = = 705,432
11!(22 − 11)!
Emmanuel Kpeglo KNUST 7
Permutations and Combinations
Example 2.5: Suppose that there are 9 faculty members in
Solution 2.5:
9! 11!
C (9,3) ⋅C (11,4) = ⋅ = 84 ⋅ 330 = 27,720
3!6! 4!7!
Emmanuel Kpeglo KNUST 8
Permutations and Combinations
NB:
integers?
Solution 2.6:
Solution 2.7:
n × n × × n = 26 4 = 456,976
Solution 2.8:
Since the letters in SUCCESS are all not same, the answer is not given
This word contains three Ss, two Cs, one U, and one E.
Note that the three Ss can be placed among the seven positions in
C(7, 3) different ways, then the two Cs can be placed in C(4, 2) ways,
then U can be placed in C(2, 1) ways, then E in C(1, 1) way.
Therefore…
7! 4! 2! 1! 7!
C (7,3)C (4,2)C (2,1)C (1,1) = ⋅ ⋅ ⋅ = = 420
3!4! 2!2! 1!1! 1!0! 3!2!1!1!
This solution leads to the following theorem…
Emmanuel Kpeglo KNUST 12
Permutations and Combinations
Theorem 2.2 (Permutations with Indistinguishable Objects):
Solution: We can consider MASS as one block along with the remaining 9 letters
A, C, H, U, S, E, T, T, S. Thus, we are permuting 10 ‘letters’.
There are 2 S’s, 2 T’s, and others 1and so the total number of permutations
sought is
n! 10!
= = 907,200
n1!n2! nk ! 2!⋅2!⋅1!1!
Emmanuel Kpeglo KNUST 13
Permutations and Combinations
Theorem 2.2 (Permutations with Indistinguishable Objects):
Solution: We can consider MASS as one block along with the remaining 9 letters
A, C, H, U, S, E, T, T, S. Thus, we are permuting 10 ‘letters’.
There are 2 S’s, 2 T’s, and others 1and so the total number of permutations
sought is
n! 10!
= = 907,200
n1!n2! nk ! 2!⋅2!⋅1!1!
Emmanuel Kpeglo KNUST 14
Binomial Coefficients and Identities
The Binomial Theorem
It is well known (a + b) 2 = a 2 + 2ab + b 2.
Multiplying this last equality by a + b one obtains
(a + b)3 = (a + b) 2 (a + b) = a 3 + 3a 2b + 3ab 2 + b3
(a + b) 4 = (a + b)3 (a + b) = a 4 + 4a 3b + 6a 2b 2 + 4ab3 + b 4
This generalizes, as we see in the next theorem.
i =0 i
Solution 2.11:
3 3 3 3
(4 x + 5)3 = (4 x)3 50 + (4 x) 2 51 + (4 x)1 52 + (4 x) 0 53
0 1 2 3
= (4 x) 3 + 3(4 x) 2 (5) + 3(4 x)(5) 2 + 53
= 64 x 3 + 240 x 2 + 300 x + 125
Solution 2.13:
25 25!
= = 5,200,300
13 13!12!
Proof:
so |A3| = 19.
|A ∪ B ∪ C|
mathematics, sixteen like theology, and eleven like accounting. It is also known that
seven like mathematics and theology, eight like theology and accounting and five like
mathematics and accounting. All three subjects are favored by four students. How many
students like neither mathematics, nor theology, nor accounting?
Solution 2.15:
Let A be the set of students liking mathematics, B the set of students liking theology, and C
be the set of students liking accounting. We are given that
Therefore
A B C = A B C
= |U| − |A ∪ B ∪ C|
= 40 − 14 − 16 − 11 + 7 + 5 + 8 − 4
and a rule for determining subsequent terms from those that precede
them.
Example 2.16
n=0: Just one good bit string of length zero, and that is l,
the empty bit string. So a0 = 1.
n=1: There are two good bit strings of length one. Namely 0
and 1. So a1 = 2.
n=3: Things start to get confusing now. But here is the list
of good bit strings of length three: 010, 011, 101, 110, and
111. So a3 = 5.
Emmanuel Kpeglo KNUST 25
Counting Using Recurrence Relations
Example 2.16…
Trying a bit more, it turns out the list continues 13, 21, 34.
classified as
• young or old,
• married or single.
Of these policyholders, 3000 are young, 4600 are male, and 7000 are married. The
policyholders can also be classified as 1320 young males, 3010 married males, and
1400 young married persons. Finally, 600 of the policyholders are young married
males.
How many of the company’s policyholders are young, female, and single?
Definition (Graph)
A graph G is an ordered pair (V , E ), where
V = V (G ) is a non-empty set of vertices – The vertex set of G ;
E = E (G ) is a set of edges the edge set of G ; and the two sets are
related through a function
fG : E → {{u, v } : u, v ∈ V }
za e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
2/20
Graph Theory - Loop and Parallel Edges
Definition
An edge e in a graph G is called a
loop if fG (e) = {u} for some vertex u ∈ V (G ) (that is, if its
endpoints coincide)
link if fG (e) = {u, v }for distinct vertices u, v ∈ V (G ).
Distinct edges e1 and e2 in a graph G are called parallel or multiple
if fG (e1 ) = fG (e2 ),that is, if they have the same endpoints. 3/20
Graph Theory - Loop and Parallel Edges
4/20
Graph Theory - Loop and Parallel Edges
Definition
A directed graph (or digraph) D is an ordered pair (V , A), where
V = V (D) is a non-empty set of vertices – the vertex set of D;
A = A(D) is a set of arcs or directed edges the arc set of D; and
the two sets are related via an incidence function fD :→ V × V ,
assigning to each arc the ordered pair of its endpoints.
5/20
Graph Theory - Directed Graph Example
If a ∈ A(D) and u, v ∈ V (D) are such that fD (a) = (u, v ), then u is called
the initial and v is called the terminal vertex of the arc a.
7/20
Graph Terminology
Graph Theory - Graph Terminology
8/20
Graph Theory - Graph Terminology
8/20
Graph Theory - Graph Terminology
8/20
Graph Theory - Graph Terminology
9/20
Graph Theory - Complete Graph
Complete Graph
A complete graph Kn (for n ≥ 1) is a simple graph with n vertices in
which every pair of distinct vertices are adjacent. More formally
V (Kn ) = {u1 , u2 , · · · , un }
E (Kn ) = {xy : x, y ∈ V , x 6= y }
9/20
Graph Theory - Complete Bi-partite Graph
10/20
Graph Theory - Complete Bi-partite Graph
11/20
Graph Theory - Bipartite Graph
Bipartite Graph
A bipartite graph Km,n (for m, n ≥ 1) is a simple graph with m + n
vertices. The vertex set partitions into sets X and Y of cardinalities m and
n. And edges are only of the form xy , where x ∈ X , y ∈ Y :
12/20
Graph Theory - Cycle
13/20
Graph Theory - Cycle
Cycle
A cycle Cn (of length n ≥ 1) is a graph with n vertices that are linked in a
circular way, creating n edges. That is,
V (Cn ) = {u1 , u2 , · · · , un }
E (Cn ) = {u1 u2 , u2 u3 , u3 u4 , · · · , un−1 un , un u1 }
13/20
Graph Theory - Cycle
Cycle
A cycle Cn (of length n ≥ 1) is a graph with n vertices that are linked in a
circular way, creating n edges. That is,
V (Cn ) = {u1 , u2 , · · · , un }
E (Cn ) = {u1 u2 , u2 u3 , u3 u4 , · · · , un−1 un , un u1 }
Note that any cycle Cn for n ≥ 3 is a simple graph, while for n = 2, the
edge set E (Cn ) consists of a pair of parallel edges.
13/20
Graph Theory - Path
14/20
Graph Theory - Path
15/20
Graph Theory - Path
Path
A path Pn (of length n ≥ 0) is a graph with n + 1 vertices that are linked
in a linear way. More precisely,
V (Pn ) = {u1 , u2 , · · · , un }
E (Pn ) = {u1 u2 , u2 u3 , u3 u4 , · · · , un−1 un }
15/20
Graph Theory - Subgraph
b c h
d e i j
G f g H k
Subgraph
Let G and H be simple graphs. We say that H is a subgraph of G if
V (H) ⊆ V (G ) and E (H) ⊆ E (G ).
16/20
Graph Theory - Subgraph
b c h
d e i j
G f g H k
Subgraph
Let G and H be simple graphs. We say that H is a subgraph of G if
V (H) ⊆ V (G ) and E (H) ⊆ E (G ).
16/20
Matrix Representation of Graphs
Matrix Representation of Graphs
Graph Theory - Incident Matrix Representation
19/20
Thank you for your attention!!
20/20
Graph Theory - Lecture 2 (of 2)
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1,
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4,
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3,
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2,
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2, deg(e)=
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2, deg(e)=3,
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2, deg(e)=3, deg(f)=
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2, deg(e)=3, deg(f)=2
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2, deg(e)=3, deg(f)=2
deg(g)=
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2, deg(e)=3, deg(f)=2
deg(g)=1.
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2, deg(e)=3, deg(f)=2
deg(g)=1.
Degree sequence is:
1/25
Graph Theory
a e1
e2 c
b e4
d e3 e5
e6 e e8
e7
G f g
Degree Sequence
deg(a)=1, deg(b)=4, deg(c)=3, deg(d)=2, deg(e)=3, deg(f)=2
deg(g)=1.
Degree sequence is: 1, 1, 2, 2, 3, 3, 4.
1/25
Graph Theory - Bipartite Graph
Bipartite Graph
A bipartite graph Km,n (for m, n ≥ 1) is a simple graph with m + n
vertices. The vertex set partitions into sets X and Y of cardinalities m and
n. And edges are only of the form xy , where x ∈ X , y ∈ Y :
3/25
Bipartite Graph, 2-Coloring and No Odd-length Cycle
Theorem
The following are equivalent:
1 G is bipartite.
2 G admits a proper 2-vertex-colouring; that is, the vertices of G can
be coloured with 2 colours (say, red and blue) so that the endpoints
of each edge receive distinct colours.
3 G has no subgraph that is a cycle of odd length.
5 6
1 2
3 4
8 7
G
Bipartite Graph, 2-Coloring and No Odd-length Cycle
Theorem
The following are equivalent:
1 G is bipartite.
2 G admits a proper 2-vertex-colouring; that is, the vertices of G can
be coloured with 2 colours (say, red and blue) so that the endpoints
of each edge receive distinct colours.
3 G has no subgraph that is a cycle of odd length.
5 6
1 2
3 4
8 7
G
3/25
Bipartite Coloring
4/25
Bipartite Coloring
4/25
Bipartite Coloring
4/25
Bipartite Coloring
4/25
Matrix Representation of Graphs
Graph Theory - Incident Matrix Representation
7/25
Graph Isomorphism
a g 5 6
b h 1 2
c i 3 4
d j 8 7
G H
a g 5 6
b h 1 2
c i 3 4
d j 8 7
G H
An Isomorphism
between G and H
a g 5 6 f (a) = 5 f (b) = 2
b h 1 2 f (c) = 3 f (d) = 7
c i 3 4 f (g ) = 1 f (h) = 6
d j 8 7 f (i) = 8 f (j) = 4
G H
8/25
Graph Isomorphism
An Isomorphism
between G and H
a g 5 6 f (a) = 5 f (b) = 2
b h 1 2 f (c) = 3 f (d) = 7
c i 3 4 f (g ) = 1 f (h) = 6
d j 8 7 f (i) = 8 f (j) = 4
G H
8/25
Graph Isomorphism
Are these two graph isomorphic?
u ∼G v ⇔ ϕ(u) ∼H ϕ(v )
for all u, v ∈ V (G ). Graphs G and H are called isomorphic (denoted
G∼ = H) if there exists an isomorphism from G to H.
9/25
Graph Isomorphism
10/25
Graph Isomorphism
Observation
To prove that graphs G and H are isomorphic, we must find an
isomorphism from G to H.
To prove that graphs G and H are not isomorphic, it suffices to find
an invariant in which G and H differ.
11/25
Graph Isomorphism -Example 1
Solution:
12/25
Graph Isomorphism -Example 1
Solution:
No. They have the same degree sequence. But these two graphs are not
isomorphic. H has a subgraph isomorphic to C3 , while G does not (it is, in
fact, bipartite and isomorphic to K3,3 ).
12/25
Graph Isomorphism -Example 2
Are these two graph isomorphic?
Solution:
13/25
Graph Isomorphism -Example 2
Are these two graph isomorphic?
Solution:
Yes, these two graphs are isomorphic. An isomorphism ϕ : (G ) → V (H) is
given by
ϕ(1) = a ϕ(2) = d
ϕ(3) = b ϕ(4) = e
ϕ(5) = c ϕ(6) = f
13/25
Graph Isomorphism -Example 3
Solution:
14/25
Graph Isomorphism -Example 3
Solution:
No, these two graphs are not isomorphic. They have the same degree
sequence, however, graph H contains no pair of adjacent vertices of degree
3, while G does.
14/25
Walks, Trails, Paths, Cycle
Walks, Trails, Paths, Cycles
Definition
Walk Let G = (V , E ) be a graph with the incidence function fG . Let
x, y ∈ V and k ∈ N. An (x, y )-walk of length k in G is an alternating
sequence of vertices and edges.
15/25
Walks, Trails, Paths, Cycles
Definition
Walk Let G = (V , E ) be a graph with the incidence function fG . Let
x, y ∈ V and k ∈ N. An (x, y )-walk of length k in G is an alternating
sequence of vertices and edges.
16/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
16/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 1a2h6n5f 1a2b3
16/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 1a2h6n5f 1a2b3
is a (1,3)-walk of length 6 that is not a trail.
16/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 1a2h6n5f 1a2b3
is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3
16/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 1a2h6n5f 1a2b3
is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3
is a (1,3)-trail of length 3 that is not a path.
16/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 1a2h6n5f 1a2b3
is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3
is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3
16/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 1a2h6n5f 1a2b3
is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3
is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3
is a (1,3)-path of length 3. 16/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 2b3j7i2h6o7i2
17/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
17/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 4d4l8k3c4
17/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
17/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
W = 2b3j7o6h2
17/25
Walks, Trails, Paths, Cycles
Definition
A walk W = v0 e1 v1 e2 v2 · · · vk1 ek vk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1 , · · · , vk are pairwise
distinct.
Connected Graph
A graph G = (V , E ) is called connected if for any x, y ∈ V there exists an
(x, y )-path (or equivalently, (x, y )-walk) in G . A graph that is not
connected is called disconnected.
18/25
Trees
19/25
Trees
Theorem 1
Let G be a graph. Then G is a tree if and only if for any two vertices
u, v ∈ V (G ), there exists a unique (u, v )-path in G .
Theorem 2 and 3
Every tree with at least 2 vertices has at least 2 vertices of degree 1
(called leaves).
Any tree with n vertices has exactly n − 1 edges.
20/25
Rooted Trees
Rooted Tree
A tree with a vertex designated as the root is called a rooted tree.
21/25
Rooted Trees
Similar terminologies for rooted trees?
22/25
Rooted Trees
Terminology for rooted trees:
Let T = (V , E ) be a rooted tree with root r and u, v ∈ V .
If u lies on the unique (v , r )-path, then u is called anancestor of v ,
and v is called a descendant to u.
If u lies on the unique (v , r )-path and uv has an edge, then u is called
the parent of v , and v is called a child of u.
If u and v have the same parent, then they are called siblings.
If vertex u has a child, then it is called an internal vertex; if it has
no children, thenit is called a leaf.
23/25
Rooted m-ary Trees
24/25
Thank you for your attention!!
25/25
CSM 166
Lecture FIVE
Topic:
Boolean Algebra
1 of 2
INTRODUCTION
.
Inputs
.
.
Network . Outputs
.
.
3. NOT (negation/complement)
AND is denoted by a dot (·).
3. NOT gate
Emmanuel Kpeglo KNUST 6
OPERATOR DEFINITIONS
A A’ A NOT A
0 1
1 0
AB A+B
A
0 0 0 A+B
B
0 1 1
1 0 1
1 1 1
Emmanuel Kpeglo KNUST
8
OPERATOR DEFINITIONS
AB A∙B
A 0 0 0
A∙B
B 0 1 0
1 0 0
1 1 1
AND Gate
AND Gate
OR Gate
NOT Gate
= XY+X'YZ+X'Z
Rearrange terms = XY+X'ZY+X'Z
Use absorption {AB+A=A} with A=X'Z and B=Y
XY+YZ+X'Z = XY+X'Z
Topic:
Boolean Algebra
2 of 2
Boolean Expressions and Boolean
Functions
Recall
Let B = {0, 1}. Then B ͫ = {(x , x ,…, x ) ∣ x ∈ B for 1 ≤ i ≤
1 2 m i
ANS: x’1x2x’3x4x5
Emmanuel Kpeglo KNUST 5
Representing Boolean Functions
Sum-of-products expansion
The sum of minterms that represents the function is called the sum-
of-products expansion or the disjunctive normal form of the
Boolean function.
Example 6.4
Find the sum-of-products expansion for the function F(x, y, z) = (x + y)z’.
The sum-of-products expansion of F is the Boolean sum of three minterms
corresponding to the three rows of this table that give the value 1 for the
function.
This gives F(x, y, z) = xyz’ + xy’z’ + x’yz’.
x y z x+y z (x + y)z
1 1 1 1 0 0
1 1 0 1 1 1
1 0 1 1 0 0
1 0 0 1 1 1
0 1 1 1 0 0
0 1 0 1 1 1
0 0 1 0 0 0
Emmanuel Kpeglo 0 KNUST0 0 0 1 0 6
Representing Boolean Functions
Maxterms
Consider variables A and B
Assume that they are somehow combined with OR operator
There are 4 possible combinations
b) x = y = z = 0. ANS: x+y+z
c) x = z = 0, y = 1. ANS: x+y’+z
Emmanuel Kpeglo KNUST 7
NAND Gate
NAND operator, defined by 1 ∣ 1 = 0 and
1∣0=0∣1=0∣0=1
NAND
X Y Z
X
0 0 1
Z 0 1 1
1 0 1
Y
1 1 0
Z = ~(X & Y)
NOR
X X Y Z
Z 0 0 1
Y 0 1 0
1 0 0
Z = ~(X OR Y) 1 1 0