Discrete Math for Computer Science. Mathematical Model Real-world Problem Computerized Solution Abstract Model Transformed Model picture of the real worldpicture.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

CS 206 Introduction to Computer Science II 04 / 01 / 2009 Instructor: Michael Eckmann.
Networks Prim’s Algorithm
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
DTU Informatics Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Informatics TexPoint fonts.
Chen, Lu Mentor: Zhou, Jian Shanghai University, School of Management Chen213.shu.edu.cn.
The Greedy Approach Chapter 8. The Greedy Approach It’s a design technique for solving optimization problems Based on finding optimal local solutions.
Lecture 21 Paths and Circuits CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
Minimal Spanning Trees – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Minimal Spanning Trees Reading: Kolman, Section 7.5.
Prim’s Algorithm from a matrix A cable TV company is installing a system of cables to connect all the towns in the region. The numbers in the network are.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
Chapter 3 The Greedy Method 3.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Computability and Complexity 23-1 Computability and Complexity Andrei Bulatov Search and Optimization.
Applied Discrete Mathematics Week 12: Trees
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
CS 206 Introduction to Computer Science II 11 / 10 / 2008 Instructor: Michael Eckmann.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
MATH 310, FALL 2003 (Combinatorial Problem Solving) Lecture 15, Friday, October 3.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Discrete Math for CS Chapter 8: Directed Graphs. Discrete Math for CS digraph: A digraph is a graph G = (V,E) where V is a finite set of vertices and.
The Shortest Path Problem
1 1 Slide © 2000 South-Western College Publishing/ITP Slides Prepared by JOHN LOUCKS.
CS 146: Data Structures and Algorithms July 21 Class Meeting
Copyright © Cengage Learning. All rights reserved.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Operations Research Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD4207 University of Palestine.
Shortest Path. Dijkstra’s Algorithm finds the shortest path from the start vertex to every other vertex in the network. We will find the shortest path.
5.1  Routing Problems: planning and design of delivery routes.  Euler Circuit Problems: Type of routing problem also known as transversability problem.
COSC 2007 Data Structures II Chapter 14 Graphs III.
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.
Structures 7 Decision Maths: Graph Theory, Networks and Algorithms.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
Fundamental Data Structures and Algorithms (Spring ’05) Recitation Notes: Graphs Slides prepared by Uri Dekel, Based on recitation.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
TSP – Upper Bounds and Lower Bounds Initial problem : Upper Bound A salesman based in Stockton needs to visit shops based in Darlington, Billingham, Middlesbrough,
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
CSCI 115 Chapter 8 Topics in Graph Theory. CSCI 115 §8.1 Graphs.
A * Search A* (pronounced "A star") is a best first, graph search algorithm that finds the least-cost path from a given initial node to one goal node out.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Graphs Upon completion you will be able to:
Graphs Chapter 28 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank Carrano.
Lecture 19 Minimal Spanning Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Example Apply hierarchical clustering with d min to below data where c=3. Nearest neighbor clustering d min d max will form elongated clusters!
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
1 1 Slide © 2005 Thomson/South-Western Chapter 9 Network Models n Shortest-Route Problem n Minimal Spanning Tree Problem n Maximal Flow Problem.
St. Edward’s University
Shortest Path Problems
Greedy Technique.
Chapter 5. Greedy Algorithms
Redraw these graphs so that none of the line intersect except at the vertices B C D E F G H.
Minimum Spanning Tree Chapter 13.6.
Spanning Trees.
Decision Maths Dijkstra’s Algorithm.
Graphs Chapter 11 Objectives Upon completion you will be able to:
Shortest Path.
Shortest Path.
Minimum spanning trees
離散數學 DISCRETE and COMBINATORIAL MATHEMATICS
Shortest Path.
Networks Prim’s Algorithm
Presentation transcript:

Discrete Math for Computer Science

Mathematical Model Real-world Problem Computerized Solution Abstract Model Transformed Model picture of the real worldpicture of the computer solution

Example Six Scottish towns – Aberdeen, Edinburgh, Fort William, Glasgow, Inverness and Perth are connected by roads. Find a road network of minimal length connecting all towns.

Real-World Model

Transformed Model Aberdeen Edinburgh Perth Inverness Glasgow Fort William

Graph A graph is a collection of vertices and edges. A weighted graph is a graph with weights assigned to each edge. A directed graph is a graph whose edges are arrows. A connected graph is a graph with a path between any two vertices. G = (V,E)‏ Example: V = { Aberdeen, Edinburgh, Perth, Fort William, Glasgow, Inverness } E = { (Aberdeen, Edinburgh), (Aberdeen, Perth),..., (Inverness, Glasgow) } Exercise: What kind of graph is ours?

Computerized Solution: An algorithm is an unambiguous sequence of instructions that yields a solution in finite time. Prim's Algorithm for a Minimum Connecting Path of Weighted Graph 1) Select any vertex and connect it to its nearest neighbour. 2) Find an unconnected vertex that is closest to the previously connected vertices and connect it 3) Repeat Step 2 until all vertices are connected

Prim's Algorithm in Action Aberdeen Edinburgh Perth Inverness Glasgow Fort William

Prim's Algorithm in Action Aberdeen Edinburgh Perth Inverness Glasgow Fort William

Prim's Algorithm in Action Aberdeen Edinburgh Perth Inverness Glasgow Fort William

Prim's Algorithm in Action Aberdeen Edinburgh Perth Inverness Glasgow Fort William

Prim's Algorithm in Action Aberdeen Edinburgh Perth Inverness Glasgow Fort William Total Distance: 339 miles

Observation: This algorithm would work just as well if applied to six towns in New York. It wouldn't be very useful if we wanted to drive the shortest route because we would have to back track. It would be a good algorithm if we wanted to pave at least one road into each town, have all towns connected somehow by paved road and wanted to pave as little as possible.

Exercises: What does Prim's Algorithm call the “minimum connecting path” we have created? Find the minimum connecting path in the following:

Expressing Algorithms in Pseudocode: Pseucocode is a combination of English and programing language structures. begin Sequence of English language descriptions end if condition Sequence of English language descriptions else Sequence of English language descriptions repeat Sequence of English language descriptions until condition SEQUENCE ITERATION SELECTION NOTE: The above can be expressed as a for-loop for all elements in a described set do something

Examples: begin input n; if n < 0 n = -1*n output n end Exercise: What does this algorithm do? begin sum := 0; for i:= 1 to n do begin j := i*i; sum := sum + j; end output sum end Exercise: What does this algorithm do?

Prim's Algorithm: begin v := any starting vertex; u := nearest adjacent vertex; Connect u and v; while unconnected vertices remain do begin u:= an unconnected vertex nearest a connected vertex; Connect u to the nearest connected vertex end

Homework Do all the exercises at the end of the chapter  1: Make your output a sequence of edges in the order they are added to the minimum connecting path.  2, 3, 5, 6: make sure your description is in everyday english and not pseudocode itself  5, 6: the trace should be in the form of a table with columns labeled by variables and lines in the table correspond to individual lines of code after execution of that line. Number the lines of code in the algorithm.  6: replace “decreasing” with “increasing”