Discrete Mathematics
Discrete Mathematics
AMTH 206
1. Logic and Proofs: Propositional logic and equivalences, Rules of inferences and 10
quantifiers, Methods of proof.
2. Induction and Recursion: Mathematical induction, Well ordering, Recursive 7
definitions and structural Induction.
3. Combinatorics: Counting principles, The principle of Inclusion and Exclusion, 8
Pigeonhole principle, Generating functions, Recurrence relations, Applications to
computer operations.
4. Graph theory and applications: Graphs and subgraphs, structure and symmetry of 7
graphs, Graph isomorphism. Trees and connectivity, Eulerian and Hamiltonian
graphs and diagraphs, Directed graphs, planar graphs.
5. Algorithms on graphs: Introduction to graphs, paths and trees. Shortest path 8
problems: Dijkstra’a algorithm, Floyd-Warshall algorithm and their comparisons.
Spanning tree problems. Kruskal’s greedy algorithm, Prim’s greedy algorithm and
their comparison.
6. Boolean algebra: Boolean functions, Logic Gates, minimization of circuits, 5
Karnaugh maps.
References
1. K. H. Rosen, Discrete Mathematics and its Applications.
2. RP Grimaldi and BV Ramana, Discrete and Combinatorial Mathematics.
www.ffms.du.ac.bd 3
Trees
Trees: A connected undirected graph that contains no simple circuit is
called a tree.
Such graphs are named tree because it resembles trees.
Because a tree cannot have a simple circuit, a tree cannot contain
multiple edges or loops. Therefore any tree must be a simple graph.
Trees are particularly useful in computer science, where they are
employed in a wide range of algorithm. For instance, trees are used to
construct efficient algorithms for locating items in a list. Trees can be
used in algorithms, to study games, to model procedures carried out
using sequence of decisions.
www.ffms.du.ac.bd 402
Spanning Tree
Spanning Tree: 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.
Example: Find a spanning tree of the simple graph G shown in the figure
www.ffms.du.ac.bd 414
Prim’s algorithm: Begin by choosing any edge with smallest weight, putting it into the
spanning tree. Successively add to the tree edges of minimum weight that are incident to a
vertex already in the tree, never forming a simple circuit with those edges already in the tree.
Stop when n 1 edges have been added.
www.ffms.du.ac.bd 415
Example: Use Prim’s Algorithm to find a
minimum spanning tree in the graph shown
in Figure 3.
www.ffms.du.ac.bd 416
We find the edge {b, f} has the minimum weight 1. Thus the vertex b and f are added to the
minimal spanning tree and edge {b, f} is added to E.
Now we consider the edges with one vertex in the tree Edge Weight
and one vertex not in the tree, that do not form simple {a, b} 2
circuits. The edges {a, b} and {f, j} have minimum {b, c} 3
weight. The edge {a, b} is selected at this stage. Hence {e, f} 4
vertex a is added to the minimal spanning tree and edge {f, g} 3
{a, b} is added to E. {f, j} 2
www.ffms.du.ac.bd 418
Next time we consider the edges with one vertex in Edge Weight Edge Weight
the tree, that do not form simple circuits. The edges {a, e} 3 {f, g} 3
{a, e}, {b, c}, {f, g}, {i, j} and {j,k} have minimum {b, c} 3 {i, j} 3
weight. The edge {a, e} is selected at this stage. {e, f} 4 {j, k} 3
Hence vertex e is added to the minimal spanning tree
and edge {a, e} is added to E.
www.ffms.du.ac.bd 419
Next time we consider the edges with one vertex in Edge Weight Edge Weight
the tree, that do not form simple circuits. The edges {e, i} 4 {i, j} 3
{b, c}, {f, g}, {i, j} and {j,k} have minimum weight. {b, c} 3 {j, k} 3
The edge {i, j} is selected at this stage. Hence vertex i {f, g} 3
is added to the minimal spanning tree and edge {i, j}
is added to E.
www.ffms.du.ac.bd 420
Next time we consider the edges with one vertex in the Edge Weight
tree, that do not form simple circuits. The edges {b, c}, {f, {b, c} 3
g}, and {j,k} have minimum weight. The edge {f, g} is {f, g} 3
selected at this stage. Hence vertex g is added to the {j, k} 3
minimal spanning tree and edge {f, g} is added to E.
www.ffms.du.ac.bd 421
Next time we consider the edges with one vertex in Edge Weight Edge Weight
the tree, that do not form simple circuits. The edge {c, {b, c} 3 {g, h} 3
g} with minimum weight is selected. Hence vertex c {j, k} 3 {g, k} 4
is added to the minimal spanning tree and edge {c, g} {c, g} 2
is added to E.
Next time we consider the edges with one vertex in Edge Weight Edge Weight
the tree, that do not form simple circuits. The edge {c, {j, k} 3 {g, h} 3
d} with minimum weight is selected. Hence vertex d {c, d} 1 {g, k} 4
is added to the minimal spanning tree and edge {c, d}
is added to E.
www.ffms.du.ac.bd 422
Figure 3: A Weighted Graph.
Next time we consider the edges with one vertex in the tree, Edge Weight
that do not form simple circuits. The edges {j, k} and {g, h}, {j, k} 3
have minimum weight. The edge {g, h} is selected at this {g, h} 3
stage. Hence vertex h is added to the minimal spanning tree {g, k} 4
and edge {g, h}, is added to E.
Next time we consider the edges with one vertex in the tree, Edge Weight
that do not form simple circuits. The edges {j, k} and {h, i}, {j, k} 3
have minimum weight. The edge {h, l} is selected at this {h, l} 3
stage. Hence vertex l is added to the minimal spanning tree {g, k} 4
and edge {h, l}, is added to E.
www.ffms.du.ac.bd 423
Figure 3: A Weighted Graph.
Next time we consider the edges with one vertex in the tree, Edge Weight
that do not form simple circuits. The edges {j, k} and {h, i}, {j, k} 3
have minimum weight. The edge {k, l} with minimum weight {k, l} 1
is selected. Hence vertex k is added to the minimal spanning {g, k} 4
tree and edge {k, l}, is added to E.
www.ffms.du.ac.bd 425
Example: Use Prim’s Algorithm to design a
minimum-cost communications network
connecting all the computers represented by
the graph in Figure 1.
Figure 1: Monthly Lease Costs for Lines in a
Computer Network.
www.ffms.du.ac.bd 426
Example: Show How Prim’s Algorithm
find a minimal spanning tree for the graph
of the Figure.
www.ffms.du.ac.bd 429
Now the minimal spanning tree is constructed with all
vertices and the edges {e, f}, {e, h}, {h, i}, {c, f}, {b, c}, {b,
d}, {a, d}, {g, h} in Figure 2. Total weight of the spanning
tree is 22
Choice Edge Weight
1 {e, f} 1
2 {e, h} 3
3 {h, i} 2 Figure 2: The minimum
Total: 22
www.ffms.du.ac.bd 430
Use Prim’s Algorithm to find a minimum spanning tree
for the given weighted graph.
www.ffms.du.ac.bd 431
Use Prim’s Algorithm to find a minimum spanning tree
for the given weighted graph.
www.ffms.du.ac.bd 432
Use Prim’s Algorithm to find a minimum spanning tree
for the given weighted graph.
www.ffms.du.ac.bd 433
Figure: A weighted graph.
Kruskal’s algorithm: Kruskal’s algorithm finds a minimal spanning tree in a connected
weighted graph G having n vertices as follows. The graph T initially consists of the vertices
of G and no edges. At each iteration, we add an edge e to T having minimum weight that does
not complete a cycle in T. When T has n 1 edges, we stop.
www.ffms.du.ac.bd 434
To carry out Kruskal’s algorithm, choose an edge in the graph
with minimum weight. Successively add edges with minimum
weight that do not form a simple circuit with those edges already
chosen. Stop after n-1 edges have been selected.
The students should know the difference between Prim’s and
Kruskal’s algorithm. In Prim’s algorithm edges of minimum
weight that are incident to a vertex already in the tree, and not
forming a circuit, are chosen; whereas in Kruskal’s algorithm
edges of minimum weight that are not necessarily incident to a
vertex already in the tree, and that do not form a circuit, are
chosen.
www.ffms.du.ac.bd 435
Example: Use Kruskal’s Algorithm to find
a minimum spanning tree in the graph
shown in Figure 3.
www.ffms.du.ac.bd 436
We find the edges {b, f}, {c, d} and {k, l} have the minimum weight 1. We choose the edge
{b, f}. Thus the vertex b and f are added to the minimal spanning tree and edge {b, f} is added
to T , i.e., T {b, f }
Next we choose the edges {c, d} and {k, l} as they don’t form a simple circuit.
Thus the vertex c, d, k and l are added to the minimal spanning tree and edges {c, d} and {k,
l} are added to T. i.e., T {b, f }, c, d , k , l
We see that the edges {a, b}, {f, j} and {c, g} have the minimum weight 2. We choose the
edges {a, b}, {f, j} and {c, g} as they don’t form a simple circuit.
www.ffms.du.ac.bd 437
Thus the vertex a, j and g are added to the minimal spanning tree and edges {a, b}, {f, j} and
{c, g} are added to T. i.e., T b, f , c, d , k , l , a, b , f , j , c, g
We see that the edges {a, e}, {b, c}, {f, g}, {g,h}, {i, j}, {j, k} and {h, l} have the minimum
weight 3. We choose the edges {a, e}, {f, g}, {g,h}, {i, j}, and {j, k} as they don’t form a
simple circuit.
Thus all the vertices are added to the minimal spanning tree and {a, e}, {f, g}, {g,h}, {i, j}, and
{j, k} are added to T. i.e.,
T b, f , c, d , k , l , a, b , f , j , c, g , a, e , f , g , g , h , i, j , j, k
www.ffms.du.ac.bd 438
Now the minimal spanning tree is constructed with all
vertices and the following edges in color in Figure 2. Total
weight of the spanning tree is 24.
Choice Edge Weight
1 {b, f} 1
2 {c, d} 1
3 {k, l} 1
4 {a, b} 2
5 {c, g} 2
6 {f, j} 2
7 {a, e} 3
8 {f, g} 3
9 {g, h} 3
10 {i, j} 3
11 {j, k} 3
Total: 24
www.ffms.du.ac.bd 439
Example: Use Kruskal’s Algorithm to design
a minimum-cost communications network
connecting all the computers represented by
the graph in Figure 1.
Figure 1: Monthly Lease Costs for Lines in a
Computer Network.
www.ffms.du.ac.bd 440
Now the minimal spanning tree is constructed
with all vertices Chicago, Atlanta, New York, San
Francisco and Denver, and edges {Chicago,
Atlanta}, {Atlanta, New York}, {San Francisco,
Denver}, and {Chicago, San Francisco}. Total
weight of the spanning tree is $3600.
Choice Edge Weight
1 {Chicago, Atlanta} $700
2 {Atlanta, New York} $800
3 {San Francisco, Denver} $900
4 {Chicago, San Francisco} $1200
Total: $3600
www.ffms.du.ac.bd 441
Show How Kruskal’s Algorithm find a
minimal spanning tree for the graph of the
Figure.
www.ffms.du.ac.bd 442
Now the minimal spanning tree is constructed with
all vertices 1, 2, 3, 4, 5 and 6, and edges {3, 4}, {1,
3}, {5, 6}, {1, 5}, and {1, 2}. Total weight of the
spanning tree is 12.
Choice Edge Weight
1 {3, 4} 1
2 {1, 3} 2
3 {5, 6} 2
4 {1, 5} 3
5 {1, 2} 4
Total: 12
www.ffms.du.ac.bd 443
R802, Section 11.5, No.2: Use Kruskal’s Algorithm
to find a minimum spanning tree for the given
weighted graph in Figure 1.
www.ffms.du.ac.bd 444
Now the minimal spanning tree is constructed with all
vertices a, b, c, d and e, and edges {a, b}, {c, d}, {a, e},
and {e, d}. Total weight of the spanning tree is 6.
Choice Edge Weight
1 {a, b} 1
2 {c, d} 1
3 {a, e} 2
4 {e, d} 2
Total: 6
www.ffms.du.ac.bd 445
R802, Section 11.5, No.3: Use Kruskal’s Algorithm to find
a minimum spanning tree for the given weighted graph
shown in Figure 1.
www.ffms.du.ac.bd 446
Now the minimal spanning tree is constructed with all
vertices and the edges {e, f}, {a, d}, {h, i}, {b, d}, {c, f}, {e,
h}, {b, c}, {g, h} in Figure 2. Total weight of the spanning
tree is 22
Choice Edge Weight
1 {e, f} 1
2 {a, d} 2
3 {h, i} 2 Figure 2: The minimum
5 {c, f} 3
6 {e, h} 3
7 {b, c} 4
8 {g, h} 4
Total: 22
www.ffms.du.ac.bd 448
Use Kruskal’s Algorithm to find a minimum spanning
tree for the given weighted graph.
www.ffms.du.ac.bd 450
Use Kruskal’s Algorithm to find a minimum
spanning tree for the given weighted graph.
www.ffms.du.ac.bd 451