0% found this document useful (0 votes)
7 views

DM Week 10

The document discusses modeling real-world settings as trees and their properties. It defines trees, rooted trees, and different types of trees like binary trees. It also covers minimum spanning trees and algorithms like Prim's and Kruskal's for finding them. Finally, it introduces abstract algebra concepts like monoids, groups and examples.

Uploaded by

Jerry Jack
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

DM Week 10

The document discusses modeling real-world settings as trees and their properties. It defines trees, rooted trees, and different types of trees like binary trees. It also covers minimum spanning trees and algorithms like Prim's and Kruskal's for finding them. Finally, it introduces abstract algebra concepts like monoids, groups and examples.

Uploaded by

Jerry Jack
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Modeling Real-World Settings as Trees

Trees
Informally, a tree is a graph that does
not have cycles.
Game Tree
A game tree is a graph representing all
possible game states and the
transitions between them for a certain
game.
 A game tree is a directed
graph whose nodes are states in
a game, and edges represent
transitions between them.

Tress and Rooted Trees


Definitions
 A tree is a connected undirected graph
with no simple circuits.
 Graphs containing no simple circuits with
no connections are called forests.
 Property : Each of their component is a
tree.
 Simple circuits are also called cycles.
 Since a tree cannot have a simple circuit,
it cannot have multiple edges or loops.
Therefore, any tree must be a simple
graph.

Rooted Trees
 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.
 A rooted tree is therefore a directed
graph.
 Suppose T is a rooted tree.
 If v is a vertex in T other than the root, the
parent of v is the unique vertex u such
that there is a directed edge from u to v.
 When u is the parent of v, v is called a
child of u.
 Vertices with same parent are called
siblings.
 The ancestors of a vertex other than the
root are the vertices in the path from the
root to this vertex, excluding the vertex
itself and including the root (that is, its
parent, it’s parents parent, and so on,
until the root is reached).
 The descendants of a vertex v are those
vertices that have v as an ancestor.
 A vertex of a rooted tree is called a leaf f it
has no children.
 Vertices that have children are called
internal vertices.
 The root is an internal vertex unless it is
the only vertex in the graph, in which case
it is a leaf.
 If a is a vertex in a tree, the subtree with a
as its root is the subgraph of the tree
consisting of a and its descendants and all
edges incident to these descendants.
 A rooted tree is called an m-ary tree if
every internal vertex has no more than m
children.
 The tree is called a full m-ary tree if every
internal vertex has exactly m children.
 An m-ary tree with m = 2 is called a binary
tree.
 An ordered rooted tree is a rooted tree
where the children of each internal vertex
are ordered.
 Ordered rooted trees are drawn so that
the children of each internal vertex are
shown in order from left to right.
 Note that a representation of a rooted
tree in the conventional way determines
an ordering for its edges.
Note : Such ordering of edges will be used in
drawing without explicit mention that a
rooted tree to be ordered is being considered.
 In an ordered binary tree ( usually called
just a binary tree ), if an internal vertex
has 2 children :
 The first child is called left child.
 The second child is called right child.
 The tree rooted at the left child of a
vertex is called the left subtree of this
vertex.
 The tree rooted at the right child of a
vertex is called the right subtree of this
vertex.

Properties of trees
Theorem : A tree with n vertices has n – 1
edges.
Proof : By induction on the number of
vertices.
BASE CASE : n=1
A tree with one vertex has 0
edges which is 1 – 1 .
INDUCTIVE STEP : Consider a tree T
with k+1 vertices. Let v be a leaf of T.
Consider the tree T’ obtained by removing v
from T .
Now, T’ has k vertices and by induction
hypothesis, k-1 edges.
Now, on adding v back to T’, the number of
edges is k-1+1 = k
This completes the proof.

Theorem : A full m-ary tree with i internal


vertices contains n = mi + 1 vertices.
For a full m-ary tree with i internal vertices,
every vertex (except the root ) is the child of
another non-leaf vertex.
Proof : Let T be a full m-ary tree with i
internal vertices.
Every vertex in T except root is the child of
an internal vertex.
Now, there are i internal vertices, each
internal vertex has m children.
So, not counting the root, number of vertices
= mi
Now, if we count the root, the number of
vertices = mi+1

Spanning Trees
Definitions
Let G be a simple graph.
 A spanning tree of G is a subgraph of G
that is a tree containing every vertex
of G.
 A simple graph with a spanning tree
must be connected, because there is a
path in the spanning tree between any
2 vertices.
Spanning Tree : Construction
Consider a simple graph G.
 Graph is connected and has cycles.
 To construct a spanning tree, find cycles
and remove edges so that cycles are no
longer present.

Weighted graphs
 Graphs with a number assigned to each
edge.
 Assigned number is the weight of the
corresponding edge.
Minimum Spanning Tree
 Spanning tree with the smallest possible
weight of edges.
 A minimum spanning tree in a connected
weighted graph is a spanning tree that has
the smallest possible sum of weights of
it’s edges.

Finding Minimum Spanning


Tree with Prim’s Algorithm
Prim’s Algorithm
 Given a weighted connected graph,
Prim’s algorithm determines a minimum
spanning tree of a graph.
 It does this by successively “growing the
tree”, starting from a minimum weight
edge.
1. Begin by choosing any edge with
smallest weight, and put it into the
spanning tree.
2. Consider edges from the graph that
are incident to a vertex already in the tree.
3. Choose a minimum weight edge that
does not form a simple circuit with thise
edges already in the tree.
4. Go to Step 2, unless n – 1 edges have
been added.
 Prim’s algorithm can determine
minimum spanning tree.
 Prim’s algorithm can determine
maximum spanning tree.

Finding Minimum Spanning


Trees with Kruskal’s
Algorithm
Kruskal’s Algorithm
 Given a weighted connected graph,
Kruskal’s algorithm determines a
minimum spanning tree of that graph.
1. Choose an edge in the graph with
minimum weight.
2. Successively add edges of minimum
weight that do not form a simple circuit
with those edges already chosen.
3. Stop after n – 1 edges have been
selected.
Abstraction and Abstract
Algebra
 Can We Abstractly Think of Operations
Such As Addition?
 Addition is an example of binary
operation.
 Addition on integers is simply a function
of the form N*N -> N.
Closed Binary Operation
 A closed binary operation is one, which
when applied to 2 elements of a set
always yields another element from the
set.
 Addition on natural numbers is a closed
binary operation.
 Subtraction on natural numbers is NOT a
closed binary operation.
Associative Binary Operation

 A binary operation defined on a set A


is said to be associative, if for all a, b, c in
A, ( a b ) c = a ( b c)
 Example : Addition on natural numbers.
 Example of non-associative operation on
natural numbers : a b =
 =
 =

Semi-Groups and Monoids


An Algebraic System
 A pair ( S , ) where S is a set and is a
binary operation on S, is called an
algebraic system.
Semi-Group
Let (S , ) be an algebraic system.
(S, ) is called a semi-group, if the
following are true:
 is a closed operation.
 is an associative operation.
Examples :
 Natural numbers with addition, forms a
semi-group.
 Natural numbers with the operation
is not a
semi-group.
Left Identity and Right Identity
 Suppose * is a binary operation on set T.
 An element el is called the left identity for
the operation *, if for every x belongs to T,
el * x = x.
 An element er is called the right identity
for the operation *, if for every x belongs
to T, x * er = x.
Theorem : el = er
Proof :
Since, el is the left identity, we have
el * er = er
Also, since, is the right identity, we have
el * er = el
Therefore, we have el = er.
Monoid
Let ( S , ) be an algebraic system.
( S , ) is called a monoid, if the following
are true:
 is a closed operation.
 is an associative operation.
 There is an identity.

Examples :
 Integers with addition form a monoid.
 Positive integers with addition form a
semi-group but not a monoid.
Groups
Inverses
 Suppose * is a binary operation on set T,
with e being the identity element.
 An element Ia is called the left inverse of
an element a belongs to T if, Ia * a = e.
 An element ra is called the right inverse of
an element a belongs to T if, ra * a = e.
Theorem : If * is a binary operation that is
associative, then la = ra.
Proof :
=
= ( By definition of right inverse)

= ( By associativity of *)

= ( By definition of right inverse)

=
 If there exists an inverse for an element a,
it is unique.
 If there are two elements b and c, such
that both b and c are inverse of a, then it
is always the case that b = c.
 Proof is along the lines of the previous
proof, where instead of the left and right
inverse, we can substitute b and c,
respectively.
 For an associative binary operation, refer
to the inverse of an element a, if it exists,
as a .
Group
Let ( S , ) be an algebraic system .
(S, ) is called a group, if the following
are true :
 is a closed operation.
 is an associative operation.
 There is an identity element e.
 Every element in S has an inverse.
Examples :
 Integers with addition Form a group, 0 is
the identity, and for every a, -a is the
inverse.
 Non-negative integers with addition form
a monoid, but not a group.
Abelian Group
 A group ( S , ) is called an abelian group
or a commutative group, if is
commutative, i.e. for all a,b belongs to S ,

 S = the set of non-zero real numbers


is a group.
 Let a be an element of group G such
that , then a must be the
identity element of group G.
 If a and b are
elements of group G.

Subgroups
 Suppose ( S , ) is a group, and
T S.
 ( T , ) is called a subgroup of S, if
( T, ) is also a group by itself.
Examples :
 Integers with addition form a group. 0
is the identity, and for every a, -a is the
inverse.
 Even integers with addition form a
subgroup of the above group.
 Odd integers with addition do not form
a subgraph of ( Z , + ).
Example
 Let R = { r0 , r60 , r120 , r180 , r240 , r300}, where
r , denotes rotation of a geometric
figure on the plane by degrees.
 Define a binary operation on R, so
that rx ry = r(x+y)mod360
 ( R , ) is a group.
 Closure and associative.
 r0 is identity.
 r(360-x)mod360 is the inverse.
 R’ = {r0 , r180 } is a subgroup.

 Let A and B be any two subgroups of


group G, then A and B will always have
atleast one common element.

Rings
Distributivity
 Suppose ( S , ) is an algebraic
system.
 * is said to distribute over if for all a,b,c
belongs to S,

a*(b c)=a*b a*c

Rings
 An algebraic system ( S , , *)is called a
ring if
(S, ) is an abelian group.
 ( S , * ) is a semigroup.
 * is distributive over .
 The identity of is called 0.
 A ring ( S , ,*) in which * is also
commutative is called a commutative
ring.
 Z, Q, R, and C are all commutative
rings.

Theorem : 0 * a = 0
Proof :
0*a=(0+0)*a
=0*a+0*a
Adding -0*a to both sides , we get
0 * a = 0.

You might also like