Discrete Mathematics: Set Theory Basics
Discrete Mathematics: Set Theory Basics
For instance :
General sets :
4. R ,real numbers
p
6. Q = :where p and q belong to Z , rational numbers
q
7. , complex numbers.
2. set builder notation x : p (x )
element discription
a, b = x : a x b
( a , b ) = x : a x b
a , b ) = x : a x b
1
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Definition 2: The sets are equal they have the same elements
iff
2. A = N , B = Z + 0
Definition 3: The empty set ( Null set ) has no elements and denoted by , .
Venn Diagram : we can use this method to represent the set graphically.
For Example :
1 3 5
1. A = 2,3,5, 7, 6,9 →
7 6 9
2
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Subsets and proper subsets
A B x ( x A and x B )
1. a, b , c , d d , c , b , a, f , s
Power sets :
Definition 7: Let S be a set ,then the power set of S is the set of all subsets of a set S ,and it is
denoted by p (S) .
2. B =
3. C =
3
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Cartesian Product :
Definition 8 : Let A and B be sets .The Cartesian product of A and B are denoted
by A B is the set of all order pairs ( a , b ) ,where a A and b B .
A B = ( a , b ) : a A and b B
Notes :
1. A B = B A IF A = B or A = or B =
2. A B = A . B
3. P (A B ) = 2 A . B
1. A B =
2. A 2 =
3. A B c =
4
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Truth sets and Quantifiers
The truth set of P (x) is denoted by x Domain : P (x)
Example : Find the truth set of each predicates when the domain is the set of
integers
1. P (x) : x 3 1 2. q(x) : x3 x
3. P (x) : x 2 3 4. P (x) : x 2 x
5. P (x) : 2x + 1 = 0
5
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Determine in which set 5 is an element
1. 5 , 5 2. 5 , 5 ,5, 5, 5
6
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Translate each of these quantification into English and determine the
truth set
1. x R , x 2 = −1
2. x Z , x 2 = 2
3. x Z , x 2 0
1. y y 2. y y 3. y y
4. x x 5. x x
1. A = a , 4,5
2. B = 0
3. C =
7
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
2.2 : Set Operations
2. ( A B ) C =
3. B c =
8
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Set Identities :
2. ( x A ) ( x B ) ( x A x B )
9
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Prove the following
1. A B = A B
10
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
2. A = A
3. A ( B C ) = ( A B ) ( A C )
4. A A =
11
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
5. A A = U
6. A =
7. A ( B C ) = ( A B ) C
12
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Definition : The intersection and union of a collection of sets are given by
n
A1 A2 ..... An = Ai
i =1
n
A1 A2 ..... An = Ai
i =1
n n
Example : Find Ai , A i for every positive integer i ,if
i =1 i =1
Example : suppose that the universal set is U = 1, 2,3, 4,5, 6, 7,8 ,express each of
the following set with bit strings
1. 1, 2, 7 2. 5
Example : Use the previous example to find the actual set that satisfy the following
0,1, 0, 0, 0, 0,1,1
13
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
2.3 : Functions
1. Domain
2. Range
3. Co-domain
14
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
One to One and Onto functions
a 1 1 a 1 a
b 2 2 b 2 b
c 3 3 c 3 c
a 1 1 a 1 a
b 2 2 b 2 b
c 3 3 c 3 c
15
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example: Let f (x ) be a function from 1, 2, 7 to a, b, c defined by f (1) = c ,
f (2) = a , f (7) = c , f (1) = b . show that f (x ) is 1-1 and onto.
Example: Let f : Z → Z and f (x ) = x 2 .show that why f (x ) not 1-1 and not
onto.
1
1. f (x ) = 2. f (x ) = x
x
16
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Inverse Function
−1
If f (a) = b a = f (b) .
Composition Functions :
g f
A B C
Note : we can use the composition function to find the inverse function .
( f f ) (x) = x
−1
and (f f ) (x) = x
−1
17
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
The floor ( ) and ceiling ( ) functions or the greatest integer function
1. x = n , n x n + 1 , x −1 n x
2. x = n , n x n +1 , x n x +1
3. x − 1 x x x + 1
4. − x = − x and − x = − x
5. x + n = x + n
Example : Find
1 5 5
Example : Find +
2 2 3
18
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Determine whether each of these functions from Z → Z is 1-1 and
onto (bijection ).
1. f (n ) = n + 1 2. f (n ) = n
2
1. f (n , m ) = m + n 2. f (n , m ) = m 2 + n 4
3. f (n , m ) = m − n
19
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Let S = −1, 0,1 ,find f (S) if
x
1. f (x) = 3 2. f (x) =
2
1. g (0)
−1
2. g (−1, 0,1)
−1
3. g (0 x 1)
−1
20
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
2.4 : Sequences and summation
Where where
a1 The first term or initial term a1 The first term or initial term
d = an +1 − an common difference an +1
d = common ratio
an
Examples : Let an be a seq. such that an = an −1 + 5 , n = 1, 2,.... and suppose that
ao = 3 ,find a1 = 3 , a2 = 3
21
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Definition :(Fibonacci Seq.)
Example : Classify the following to Arithmetic or Geometric ,then find the general
form
1- 3, 6,12,.....
1 1 1
2- , , , .....
3 9 27
3- 3, 6, 9,.....
an = n an −1 + n 2 an − 2 , a = 1 , a1 = 2
22
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Determine ,if the following seq. an = 3n is a solution of
an = 2an −1 − an −2 , n = 2,3,...
n (n + 1)
n 2
1
k =1
k =
3
2 x
k =0
k
=
1− x
, x 1
1
k x k −1 = , x 1
(1 − x )
2
k =1
1. i
i =1
=
2. ii =1
2
=
24
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
15
3. i
i =7
2
=
4 3
4. (i + j ) =
i =1 j =1
( 2.3 )
20
5.
j
+ 2j =
i =0
( 3 + (−1) ) =
20
j
Question : Find
i =0
25
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Logic ( Preposition Logic )
Definition: A statement or preposition is declarative sentence that is either true or
false but not both.
Examples of preposition
1. 2 + 4 = 6 . 2. 3 + 4 =9
3. The sun will come tomorrow. 3. Amman is the capital of Jordan.
Boolean Operators
1. Negation ( Not ) , ( )
Example : Give the negation of the following
1. P : 3+5 > 7 2. Q : it is cold
26
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
5. Implication ( implies ) ( → ) p→q
p q p→q Hypothesis Conclusion
T T T
T F F
F T T
F F T
Example : choose the correct answer of the following
1. If Sunday is a day of the week, then 1+3=5 . ( T ,F )
2. If you went to school, then September is a month . ( T , F )
2. p q :
3. p q :
4. p q :
5. p → q :
6. p q :
7. p ( p q) :
27
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Note : we will use the following form in the solution of combinatorial circuits
1. 2 + 2 = 4 iff 1 + 1 = 2 . ( )
2. If 1 + 1 = 3 ,then 2 + 2 = 4 . ( )
28
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : show that if the following statements are equivalent by truth table
p → (q → r ) and q → ( p r)
29
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Exercises :
b. ( p r q) a. ( p → q) (p → q)
3. Let p and q be the propositions “The election is decided” and “The votes
have been counted, "respectively.
Express each of these compound propositions as an English sentence.
a) ¬p b) p ∨ q c) ¬p ∧ q
d) q → p e) ¬q →¬p f) p↔q
g) ¬q ∨ (¬p ∧ q)
30
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
2.6 Matrices
Definition : A matrix is a rectangular array of number with m-rows and n-
columns .
a11 a12 . . a1n
a a 22 . . a 2 n
21
The general form of any matrix is . . where a ij is element or
. .
a m1 . . . a mn
entry .
Note :
3. The matrices are equal iff the corresponding entries in every position are
equal .
If A and B are two matrices then If A and B are two matrices then we can
A B = aij bij product A and B iff the number of
columns in A = the number of rows in B .
1 4 3 5 2 1
Example : If A = 6 0 3 , B= ,find
4 1 8
1. The size of A and B .
2. a 23 = a 21 =
3. A+B=
31
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
2
1 4 3
Example : If A = 6 0 3 , B = 3 ,find A . B
1
where ij = 1 if i= j and ij = 0 if i j.
1 0 0
For example : I 3 = 0 1 0
0 0 1
A0 = I n , Ar =
A
A ....
A
r −times
32
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
7 1 3
Example : If A = ,find
6 2 5
Boolean Operations
1. The join of any two sets A and B are denoted by A B .
1 0
1 1 1
Example : If A = 0 0 1 , B = 1 1 ,find
0 0
1. AB
2. A2
33
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Inverse Matrix
We can find the inverse matrix for any Square matrix ( A) if the determinant of a
matrix not equal zero ( A 0 ) .
a c
−1 1 d − c
1. If A = A = A .− b , where A = a.d − b.c
b d a
T
e f d f d e
−
a b c h i g i g h
1 b b
A = d f
c a c a
A −1 = .− −
h
2. If e
A h i g i g
g h i
b c a c a b
e −
f d f d e
3 1
1. A =
4 5
2 5 6
2. A = 4 0 2
1 1 3
34
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
1 1 1 1
Practice 1: If A = , B= ,find
0 1 1 0
1. AB 2. A2 3. A B 4. A B
− 2 5 1
3 4
1. A= 2. A = 4 4 2
− 2 − 3
1 1 0
35
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Properties of divisibility
1. a \ 0
2. (a \ b) (a \ c) a \ (b + c)
3. a \ b a \ (b.c)
4. (a \ b) (b \ c) a \ c
Proof :
36
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Modular Congruence
37
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Theorem : Let m Z + , if a (mod m) and c d (mod m) ,then
1. a + c (b + d )(mod m) 2. a.c (b.d )(mod m)
Arithmetic Modulo m
1. 80
2. -29
Practice 4 : Find the modulo 5
Practice 5 : Suppose that a , b Z , a 4(mod 13) , b 9(mod 13) ,find the
integer c with 0 c 12 .
1. c 9a (mod 13) 2. c (a + b) (mod 13)
38
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
39
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Prime Numbers
Any integer number p 1 is prime it is not the product of any two integers
greater than 1.
40
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
3. gcd(15 , 30 , 105)
41
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Determine whether the integers in each of these sets are relatively
prime
1. 21 , 23 , 55 2. 14 , 12 , 32
Example : Find
1. gcd(91 , 287) 2. gcd(111 , 201)
42
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Mathematical Induction
n −1
Example : By mathematical induction show that n! 2 , n 1
43
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
44
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Relations :
Example : If A = a , b , c , d , e , f , g , h , A1 = a , b , c , A 2 = f , g , h
A 3 = d , e , f , g , h , A 4 = b , f , A5 = d, c , A 6 = f , g , h
Describe which of the following is a partition of A .
1. A1 , A 2 2. A1 , A 5 , A 6 3. A 3 , A 4
+
Example : Let A Z , R is the relation defined by
aRb 2a b + 1 , which of the following is a relation
A1 = (1, 4) (2, 5) (3, 7)
A 2 = (2, 2) (1, 5) (3,8)
45
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : List all order pairs in the following relation
R = (a, b) : a divides b on the set 1, 2,3, 4,5
Properties of relations
1. A relation R on a set A is called reflexive if (a, a) R , a A
2. A relation R on a set A is called symmetric if (b , a) R ,whenever
(a, b ) R , a, b A
R 5 = (2, 3)
R 6 = (1,1) (1, 2) (1, 4) (1, 3) (2, 2) (2, 3) (2, 4) (3, 3)(3, 4)(4, 4)
46
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Representing Relaion:
1. Matrix of relations
A relation between finite sets can be represenred using a zero – one matrix.
1 , (ai , b j ) R
MR =
m ij
m ij =
and
1 , (ai , b j ) R
Example : Let A = 1, 2, 3 , B = a , b ,explain if
,then represent R by matrix [Link] a relation R = (2, a) (3, b) (1, a)(1, b)
We can apply the properties of the relation on a matrix form by the following steps:
1. Reflexive The main diagonal of M R is 1 .
2. Symmetric m ij = 1 whenever m ji = 1. ( m ij = m ji )
or
Symmetric M R = M R T
3. Antisymmetric m ij = 1 , m ji = 0 when i j .
or
Antisymmetric m ij = m ji = 0 when i j
0 1 0
2. M R =
0 1 0
0 1 0
1 0 1
3. M R =
0 1 0
1 0 1
Example : list the oreder pairs for the previous example .
2. Digraph of relations
48
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
To display the relation by digraph
- Draw a small circle for each element in A
- Use the order pairs to connect between the elements.
Note : Circles = Vertices , Lines = Edges
1 1 0
2. A = 1, 2, 3 , MR =
0 1 1
0 1 1
Combining Relations
49
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Let A = 1, 2,3 , B = 1, 2,3, 4 be sets ,and
R1 = (1,1) (1, 2) (1, 4) , R 2 = (1,1) (2, 2) find
1. R1 R2 =
2. R1 R2 =
3. R1 − R 2 =
4. R1 R 2 =
Example : Let
R1 = (1,1) (1, 3) (2, 3)(2, 4)(3,1) , R 2 = (2,1) (3,1)(3, 2)(4, 2)
find ( S R )
50
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Question : Consider the following relations on A = 1, 2,3, 4
R1 = (2, 2) (2, 3) (2, 4) (3, 2) (3, 3) (3, 4)
R 2 = (1,1) (1, 2) (2,1) (2, 2) (3, 3) (4, 4)
R 3 = (2, 4) (4, 2)
R 4 = (1, 2) (2, 3) (3, 4)
R 5 = (1,1)(2, 2)(3, 3)(4, 4)
R 6 = (1, 3) (1, 4) (2, 3) (2, 4) (3,1) (3, 4)
51
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Path in Digraph
2. If the path begins and ends at the same vertex then is called circuit or cycle .
Example : which of the following are paths ,then find the length of ach path and determine
which one is called cycle
1. a, b, c, e
2. b, e, c, b, e
3. a, a, b, e, d , e
4. b, c, e, d , a, a, b
5. b, c, c, b, e, d , e, d
6. a, a, b, b, c, c, b, e, d ,
52
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Graph
In this section ,we will explain the different types of graphs with its suitable example .
1. Undirected graph : In this case the direction of edge does not obtain(exist).(without
direction )
6. Self loop graph :the edge from v1 to v1 .(From the vertex to itself )
7. Simple graph : A graph in which there is no self loop graph and parallel edges .
8. Multiple graph : is a graph with multiple edges between the same vertices and loops are
allowed
53
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
The Degree of vertices in an undirected graph :
Definition : The degree of vertex in an undirected graph is the number of edges that
Example : How many edges are there in a graph with 10 vertices each of degree 6 ?
54
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
55
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example :determine whether the graph shown has directed or undirected edges,
whether it has multiple edges, and whether it has one or more loops.
56
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Adjacency Matrices :
1 , if {v ,v }is an edge of G
if its adjacency matrix is A = aij , then aij = i j
0 , otherwise
Example : Draw a graph with the adjacency matrix of the following graph
57
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Question :determine whether the graph shown has directed or undirected edges,
whether it has multiple edges, and whether it has one or more loops.
58
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
This graph has directed edges, multiple edges, and two loops.
59
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Trees
Introduction to trees
Definition : A tree is a connected undirected graph with no simple circuit .
(without multiple edges or loops )
For instance :
Definition : A rooted tree is a tree in which one vertex has been designated as the
root and every edge is directed away from the root.
60
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
1. The parent of c . ( )
2. The children g . ( )
3. The sibling of h. ( )
4. All ancestors of e. ( )
5. The descendants of b. ( )
6. The internal vertices . ( )
7. The leaves . ( )
8. The sub-tree rooted at g.
62
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Use the following graph to answer
Properties of trees
Example : How many vertices does a full 5-ary tree with 100 internal vertices have?
Example : How many edges does a full binary tree with 1000 internal vertices have?
Example : How many leaves does a full 3-ary tree with 100 vertices have?
63
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Note : The height of a rooted tree is the maximum of the levels of vertices
Note : A rooted tree with many m-ary of height h is balanced ,if all leaves are at level h
or h-1 .
64
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : Construct the tree of the following expression
1. (7 + (6 − 2)) − ( x − ( y − 3))
2. ((3 + x) − (3 − x)) − ( x + 3)
65
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Traversal Algorithms
Procedures for systematically visiting every vertex of an ordered rooted tree.
1. Preorder Traversal
Visit the root search the left subtree search the right subtree
2. Inorder Traversal
Visit the left subtree Visit the root Visit the right subtree
3. postorder Traversal
Visit the left subtree Visit the right subtree Visit the root
Example : In which order are the vertices of the ordered rooted tree visited using
1. A preorder traversal
2. An inorder traversal
Example : In which order are the vertices of the ordered rooted tree visited using
1. A preorder traversal
2. An inorder traversal
66
The University of Jordan –Aqaba Branch
Ahmed Alsarairah Discrete Mathematics
--------------------------------------------------------------------------------------------------------------------------------------------
Example : In which order are the vertices of the ordered rooted tree visited using
1. A preorder traversal
2. An inorder traversal
67