0% found this document useful (0 votes)
6 views42 pages

Discrete Mathematics

Uploaded by

abdur rahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views42 pages

Discrete Mathematics

Uploaded by

abdur rahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

Discrete Mathematics

AMTH 206

Second Year Honours: 2018-2019


Department of Applied Mathematics

Zavid Iqbal Bangalee, PhD


Associate Professor
University of Dhaka, Dhaka 1000
Email: raaz2015@yahoo.com
Website: www.ffms.du.ac.bd
Class
Sr. Topics Hours

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.

Evaluation: Incourse Assessment 30 Marks, Final examination (Theory, 3 hours) 70 Marks.


Eight questions of equal value will be set, of which any five are to be answered.

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

Solution: The graph G is connected, but it is not a


tree because it contains simple circuits. Remove the
edges  a, e ,  e, f  and  c, g to produce a simple

graph with no simple circuits. The subgraph is a


spanning tree because it is a tree that contains every
vertex of G. www.ffms.du.ac.bd 412
Minimum Spanning Tree: A minimum spanning tree in a connected
weighted graph is a spanning tree that has the smallest possible sum of
weights of its edges.

A Greedy Algorithm: A greedy algorithm is a procedure that makes an


optimal choice at each of its step. Optimizing at each step does not
guarantee that the optimal overall solution is produced. However,
Prim’s and Kruskal’s algorithms for constructing minimum spanning
trees are greedy algorithms that do produce optimal solutions.

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.

Figure 3: A Weighted Graph.


Solution: We solve this problem by finding a minimum spanning tree in the graph in Figure
3. Prim’s algorithm is carried out by choosing an initial edge of minimum weight and
successively adding edges of minimum weight that are incident to a vertex in the tree and that
do not form simple circuits.

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

Figure 3: A Weighted Graph.


www.ffms.du.ac.bd 417
Next time we consider the edges with one vertex in the Edge Weight
tree, that do not form simple circuits. The edge {f, j} with {a, e} 3
minimum weight is selected. Hence vertex j is added to {b, c} 3
the minimal spanning tree and edge {f, j} is added to E. {e, f} 4
{f, g} 3
{f, j} 2

Figure 3: A Weighted Graph.

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.

Figure 3: A Weighted Graph.

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.

Figure 3: A Weighted Graph.

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.

Figure 3: A Weighted Graph.

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.

Figure 3: A Weighted Graph.


www.ffms.du.ac.bd 424
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 {a, b} 2
3 {f, j} 2
4 {a, e} 3
5 {i, j} 3
6 {f, g} 3
7 {c, g} 2
8 {c, d} 1
9 {g, h} 3
10 {h, l} 3
11 {k, l} 1
Total: 24

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.

Figure 1: Six cities 1-6 and the costs of


building roads between certain pairs of them.

Now the minimal spanning tree is constructed with


all vertices 1, 2, 3, 4, 5 and 6, and edges {3, 4}, {3,
1}, {1, 5}, {5, 6}, and {1, 2}. Total weight of the
spanning tree is 12.
Choice Edge Weight
1 {3, 4} 1
2 {3, 1} 2
3 {1, 5} 3
4 {5, 6} 2
5 {1, 2} 4
www.ffms.du.ac.bd 427
Total: 12
R802, Section 11.5, No.2: Use Prim’s Algorithm to
find a minimum spanning tree for the given weighted
graph in Figure 1.

Figure 1: A weighted graph.

Now the minimal spanning tree is constructed with all


vertices a, b, c, d and e, and edges {a, b}, {a, e}, {e, d},
and {c, d}. Total weight of the spanning tree is 6.
Choice Edge Weight
1 {a, b} 1
2 {a, e} 2
3 {e, d} 2
4 {c, d} 1

Total: 6 www.ffms.du.ac.bd 428


R802, Section 11.5, No.3: Use Prim’s Algorithm to find a
minimum spanning tree for the given weighted graph shown
in Figure 1.

Figure 1: A Weighted Graph.

R802, Section 11.5, Exercises 1-8.


G639 Section 13.1, Examples 13.3, 13.4, Exercises 1.

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

{c, f} spanning tree .


4 3
5 {b, c} 4
6 {b, d} 3
7 {a, d} 2
8 {g, h} 4

Total: 22

www.ffms.du.ac.bd 430
Use Prim’s Algorithm to find a minimum spanning tree
for the given weighted graph.

Figure: A weighted graph.

www.ffms.du.ac.bd 431
Use Prim’s Algorithm to find a minimum spanning tree
for the given weighted graph.

Figure: A weighted graph.

Use Prim’s Algorithm to find a minimum spanning tree


for the given weighted graph.

Figure: A weighted graph.

www.ffms.du.ac.bd 432
Use Prim’s Algorithm to find a minimum spanning tree
for the given weighted graph.

Figure: A weighted graph.

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.

Figure 3: A Weighted Graph.


Solution: We solve this problem by finding a minimum spanning tree in the graph in Figure
3. Kruskal’s algorithm is carried out by choosing an initial edge of minimum weight and
successively adding edges with minimum weight that do not form simple circuits.
Initially T  .

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.

Figure: Six cities 1-6 and the costs of building


roads between certain pairs of them.

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.

Figure 1: A weighted graph.

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.

Figure 1: A Weighted Graph.

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

4 {b, d} 3 spanning tree .

5 {c, f} 3
6 {e, h} 3
7 {b, c} 4
8 {g, h} 4

Total: 22

R802, Section 11.5, Exercises 1-8.


G639 Section 13.1, Examples 13.3, 13.4, Exercises 1.
www.ffms.du.ac.bd 447
Use Kruskal’s Algorithm to find a minimum spanning
tree for the given weighted graph.

Figure: A weighted graph.


Use Kruskal’s Algorithm to find a minimum spanning
tree for the given weighted graph.

Figure: A weighted graph.

www.ffms.du.ac.bd 448
Use Kruskal’s Algorithm to find a minimum spanning
tree for the given weighted graph.

Figure: A weighted graph.

Use Kruskal’s Algorithm to find a minimum spanning


tree for the given weighted graph.

Figure: A weighted graph.


www.ffms.du.ac.bd 449
J465, Section 9.4, No.4: Use Kruskal’s Algorithm to
find a minimum spanning tree for the given weighted
graph.

Figure: A weighted graph.


Ans: Total weight 32,
T 1,5 ,  5,8 , 11,12 , 1, 2 ,  5, 6 ,  7,10 , 10,8 , 9,12 ,  2,3 ,  4,5 , 8,5

www.ffms.du.ac.bd 450
Use Kruskal’s Algorithm to find a minimum
spanning tree for the given weighted graph.

Figure: A weighted graph.

www.ffms.du.ac.bd 451

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy