May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Trees Chapter 11.
2012: J Paul GibsonT&MSP: Mathematical FoundationsMAT7003/L2-GraphsAndTrees.1 MAT 7003 : Mathematical Foundations (for Software Engineering) J Paul Gibson,
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
Shortest Paths Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 9.6 Based on slides from Chuck Allison, Michael T.
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
CMPS 2433 Discrete Structures Chapter 5 - Trees R. HALVERSON – MIDWESTERN STATE UNIVERSITY.
1 Chapter 10 Trees. Tree Definition 1. A tree is a connected undirected graph with no simple circuits. Theorem 1. An undirected graph is a tree if and.
1 Copyright M.R.K. Krishna Rao 2003 Ch 9 - Trees Definition: A tree is a connected undirected graph with no simple circuits. Since a tree cannot have a.
1 Section 9.1 Introduction to Trees. 2 Tree terminology Tree: a connected, undirected graph that contains no simple circuits –must be a simple graph:
Applied Discrete Mathematics Week 12: Trees
Rooted Trees. More definitions parent of d child of c sibling of d ancestor of d descendants of g leaf internal vertex subtree root.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Trees.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Let us switch to a new topic:
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The trees.
Trees and Tree Traversals Prof. Sin-Min Lee Department of Computer Science San Jose State University.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The distance.
Graph Theory Topics to be covered:
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Section 10.1 Introduction to Trees These class notes are based on material from our textbook, Discrete Mathematics and Its Applications, 6 th ed., by Kenneth.
May 1, 2002Applied Discrete Mathematics Week 13: Graphs and Trees 1News CSEMS Scholarships for CS and Math students (US citizens only) $3,125 per year.
Foundations of Discrete Mathematics
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Euler paths and tours.
Tree A connected graph that contains no simple circuits is called a tree. Because a tree cannot have a simple circuit, a tree cannot contain multiple.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
Discrete Structures Lecture 12: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
5.5.3 Rooted tree and binary tree  Definition 25: A directed graph is a directed tree if the graph is a tree in the underlying undirected graph.  Definition.
Discrete Structures Trees (Ch. 11)
Chap 8 Trees Def 1: A tree is a connected,undirected, graph with no simple circuits. Ex1. Theorem1: An undirected graph is a tree if and only if there.
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Graphs Discrete Structure CS203. Adjacency Matrix We already saw a way of representing relations on a set with a Boolean matrix: R digraph(R) M R1234.
5.5.2 M inimum spanning trees  Definition 24: A minimum spanning tree in a connected weighted graph is a spanning tree that has the smallest possible.
Shortest Paths Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 8.6 Based on slides from Chuck Allison, Michael T.
Discrete Mathematics Chapter 5 Trees.
M180: Data Structures & Algorithms in Java Trees & Binary Trees Arab Open University 1.
Trees Dr. Yasir Ali. A graph is called a tree if, and only if, it is circuit-free and connected. A graph is called a forest if, and only if, it is circuit-free.
Chapter 10: Trees A tree is a connected simple undirected graph with no simple circuits. Properties: There is a unique simple path between any 2 of its.
CHAPTER 11 TREES INTRODUCTION TO TREES ► A tree is a connected undirected graph with no simple circuit. ► An undirected graph is a tree if and only.
BINARY TREES Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary.
Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 9 Trees.
Discrete Mathematics Chapter 10 Trees.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Chapter 11. Chapter Summary Introduction to Trees Applications of Trees (not currently included in overheads) Tree Traversal Spanning Trees Minimum Spanning.
Section10.1: Introduction to Trees
Applied Discrete Mathematics Week 15: Trees
Shortest Path Problems
Let us switch to a new topic:
Graph Graphs and graph theory can be used to model:
Discrete Mathematicsq
Trees Chapter 11.
12. Graphs and Trees 2 Summary
Introduction to Trees Section 11.1.
Graphs.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Trees.
Shortest Paths Discrete Mathematics and Its Applications (7th Edition)
Discrete Mathematics and Its Applications (5th Edition)
Shortest Paths Discrete Mathematics and Its Applications (7th Edition)
Graphs Discrete Structure CS203.
Trees L Al-zaid Math1101.
Discrete Mathematics and Its Applications (5th Edition)
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
And the Final Subject is…
Shortest Paths Discrete Mathematics and Its Applications (8th Edition)
Shortest Paths Discrete Mathematics and Its Applications (7th Edition)
Shortest Paths Discrete Mathematics and Its Applications (7th Edition)
Presentation transcript:

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices a = v 0, v 1, …, v n = z and positive weights w(v i, v j ), where w(v i, v j ) =  if {v i, v j } is not an edge in G) for i := 1 to n L(v i ) :=  L(a) := 0 S :=  {the labels are now initialized so that the label of a is zero and all other labels are , and the distinguished set of vertices S is empty}

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 2 Dijkstra’s Algorithm while z  S begin u := the vertex not in S with minimal L(u) S := S  {u} for all vertices v not in S if L(u) + w(u, v) < L(v) then L(v) := L(u) + w(u, v) {this adds a vertex to S with minimal label and updates the labels of vertices not in S} end {L(z) = length of shortest path from a to z}

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 3 Dijkstra’s Algorithm Example: abdz ec    Step 0

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 4 Dijkstra’s Algorithm Example: abdz ec    Step 1 4 (a) 2 (a)

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 5 Dijkstra’s Algorithm Example: abdz ec    Step 2 4 (a) 2 (a) 3 (a, c) 10 (a, c) 12 (a, c)

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 6 Dijkstra’s Algorithm Example: abdz ec    Step 3 4 (a) 2 (a) 3 (a, c) 10 (a, c) 12 (a, c) 8 (a, c, b)

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 7 Dijkstra’s Algorithm Example: abdz ec    Step 4 4 (a) 2 (a) 3 (a, c) 10 (a, c) 12 (a, c) 8 (a, c, b) 10 (a, c, b, d) 14 (a, c, b, d)

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 8 Dijkstra’s Algorithm Example: abdz ec    Step 5 4 (a) 2 (a) 3 (a, c) 10 (a, c) 12 (a, c) 8 (a, c, b) 10 (a, c, b, d) 14 (a, c, b, d) 13 (a, c, b, d, e)

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 9 Dijkstra’s Algorithm Example: abdz ec    Step 6 4 (a) 2 (a) 3 (a, c) 10 (a, c) 12 (a, c) 8 (a, c, b) 10 (a, c, b, d) 14 (a, c, b, d) 13 (a, c, b, d, e)

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 10 The Traveling Salesman Problem The traveling salesman problem is one of the classical problems in computer science. A traveling salesman wants to visit a number of cities and then return to his starting point. Of course he wants to save time and energy, so he wants to determine the shortest path for his trip. We can represent the cities and the distances between them by a weighted, complete, undirected graph. The problem then is to find the circuit of minimum total weight that visits each vertex exactly once.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 11 The Traveling Salesman Problem Example: What path would the traveling salesman take to visit the following cities? ChicagoToronto New York Boston Solution: The shortest path is Boston, New York, Chicago, Toronto, Boston (2,000 miles).

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 12 The Traveling Salesman Problem Question: Given n vertices, how many different cycles C n can we form by connecting these vertices with edges? Solution: We first choose a starting point. Then we have (n – 1) choices for the second vertex in the cycle, (n – 2) for the third one, and so on, so there are (n – 1)! choices for the whole cycle. However, this number includes identical cycles that were constructed in opposite directions. Therefore, the actual number of different cycles C n is (n – 1)!/2.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 13 The Traveling Salesman Problem Unfortunately, no algorithm solving the traveling salesman problem with polynomial worst-case time complexity has been devised yet. This means that for large numbers of vertices, solving the traveling salesman problem is impractical. In these cases, we can use approximation algorithms that determine a path whose length may be slightly larger than the traveling salesman’s path, but can be computed with polynomial time complexity. For example, artificial neural networks can do such an efficient approximation task.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 14 Let us talk about… Trees

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 15Trees Definition: A tree is a connected undirected graph with no simple circuits. Since a tree cannot have a simple circuit, a tree cannot contain multiple edges or loops. Therefore, any tree must be a simple graph. Theorem: An undirected graph is a tree if and only if there is a unique simple path between any of its vertices.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 16Trees Example: Are the following graphs trees? No. Yes. Yes. No.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 17Trees Definition: An undirected graph that does not contain simple circuits and is not necessarily connected is called a forest. In general, we use trees to represent hierarchical structures. We often designate a particular vertex of a tree as the root. Since there is a unique path from the root to each vertex of the graph, we direct each edge away from the root. Thus, a tree together with its root produces a directed graph called a rooted tree.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 18 Tree Terminology If v is a vertex in a rooted tree 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 the child of u. Vertices with the 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.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 19 Tree Terminology The descendants of a vertex v are those vertices that have v as an ancestor. A vertex of a tree is called a leaf if it has no children. Vertices that have children are called internal vertices. If a is a vertex in a tree, then 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.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 20 Tree Terminology The level of a vertex v in a rooted tree is the length of the unique path from the root to this vertex. The level of the root is defined to be zero. The height of a rooted tree is the maximum of the levels of vertices.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 21Trees Example I: Family tree James ChristineBob FrankJoycePetra

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 22Trees Example II: File system / usrtemp binspoolls bin

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 23Trees Example III: Arithmetic expressions  +- yzxy This tree represents the expression (y + z)  (x - y).

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 24Trees Definition: 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. Theorem: A tree with n vertices has (n – 1) edges. Theorem: A full m-ary tree with i internal vertices contains n = mi + 1 vertices.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 25 Binary Search Trees If we want to perform a large number of searches in a particular list of items, it can be worthwhile to arrange these items in a binary search tree to facilitate the subsequent searches. A binary search tree is a binary tree in which each child of a vertex is designated as a right or left child, and each vertex is labeled with a key, which is one of the items. When we construct the tree, vertices are assigned keys so that the key of a vertex is both larger than the keys of all vertices in its left subtree and smaller than the keys of all vertices in its right subtree.

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 26 Binary Search Trees Example: Construct a binary search tree for the strings math, computer, power, north, zoo, dentist, book. math

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 27 Binary Search Trees Example: Construct a binary search tree for the strings math, computer, power, north, zoo, dentist, book. math computer

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 28 Binary Search Trees Example: Construct a binary search tree for the strings math, computer, power, north, zoo, dentist, book. math computer power

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 29 Binary Search Trees Example: Construct a binary search tree for the strings math, computer, power, north, zoo, dentist, book. math computer power north

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 30 Binary Search Trees Example: Construct a binary search tree for the strings math, computer, power, north, zoo, dentist, book. math computer power northzoo

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 31 Binary Search Trees Example: Construct a binary search tree for the strings math, computer, power, north, zoo, dentist, book. math computer power northzoodentist

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 32 Binary Search Trees Example: Construct a binary search tree for the strings math, computer, power, north, zoo, dentist, book. math computer power northzoodentistbook

May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 33 Binary Search Trees To perform a search in such a tree for an item x, we can start at the root and compare its key to x. If x is less than the key, we proceed to the left child of the current vertex, and if x is greater than the key, we proceed to the right one. This procedure is repeated until we either found the item we were looking for, or we cannot proceed any further. In a balanced tree representing a list of n items, search can be performed with a maximum of  log(n + 1)  steps (compare with binary search).