CSE 589 Applied Algorithms Course Introduction. CSE 589 - Lecture 1 - Spring 1999 2 Instructors Instructor –Richard Ladner –206.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Comp 122, Spring 2004 Greedy Algorithms. greedy - 2 Lin / Devi Comp 122, Fall 2003 Overview  Like dynamic programming, used to solve optimization problems.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
Introduction to Algorithms 6.046J/18.401J L ECTURE 16 Greedy Algorithms (and Graphs) Graph representation Minimum spanning trees Optimal substructure Greedy.
Graph Searching CSE 373 Data Structures Lecture 20.
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
Graphs COL 106 Slide Courtesy : Douglas W. Harder, U Waterloo.
CSE 589 Applied Algorithms Spring 1999 Course Introduction Depth First Search.
1 Spanning Trees Lecture 20 CS2110 – Spring
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 13 Minumum spanning trees Motivation Properties of minimum spanning trees Kruskal’s.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
CSE 326: Data Structures Spanning Trees Ben Lerner Summer 2007.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Design and Analysis of Algorithms Minimum Spanning trees
Tirgul 7 Review of graphs Graph algorithms: – BFS (next tirgul) – DFS – Properties of DFS – Topological sort.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
Instructor: Dr. Sahar Shabanah Fall Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.
Data Structures Using C++ 2E
1.1 Data Structure and Algorithm Lecture 13 Minimum Spanning Trees Topics Reference: Introduction to Algorithm by Cormen Chapter 13: Minimum Spanning Trees.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Week -7-8 Topic - Graph Algorithms CSE – 5311 Prepared by:- Sushruth Puttaswamy Lekhendro Lisham.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Lecture 12-2: Introduction to Computer Algorithms beyond Search & Sort.
Minimum Spanning Trees
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Introduction to Algorithms L ECTURE 14 (Chap. 22 & 23) Greedy Algorithms I 22.1 Graph representation 23.1 Minimum spanning trees 23.1 Optimal substructure.
Spring 2015 Lecture 11: Minimum Spanning Trees
COSC 2007 Data Structures II Chapter 14 Graphs III.
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
CSE332: Data Abstractions Lecture 24.5: Interlude on Intractability Dan Grossman Spring 2012.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Minimum Spanning Trees CS 146 Prof. Sin-Min Lee Regina Wang.
Graphs Slide credits:  K. Wayne, Princeton U.  C. E. Leiserson and E. Demaine, MIT  K. Birman, Cornell U.
Minimum Spanning Trees CSE 373 Data Structures Lecture 21.
1 22c:31 Algorithms Minimum-cost Spanning Tree (MST)
Graphs 2015, Fall Pusan National University Ki-Joune Li.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graph Searching CSIT 402 Data Structures II. 2 Graph Searching Methodology Depth-First Search (DFS) Depth-First Search (DFS) ›Searches down one path as.
CSE 589 Applied Algorithms Spring 1999 Prim’s Algorithm for MST Load Balance Spanning Tree Hamiltonian Path.
Graphs. What is a graph? In simple words, A graph is a set of vertices and edges which connect them. A node (or vertex) is a discrete position in the.
Lecture 11 Graph Algorithms
Algorithm Analysis Fall 2017 CS 4306/03
CSCE 411 Design and Analysis of Algorithms
Introduction to Algorithms
Lecture 12 Algorithm Analysis
CC 215 Data Structures Graph Searching
I206: Lecture 15: Graphs Marti Hearst Spring 2012.
CS120 Graphs.
Graph Algorithm.
Graphs Chapter 13.
CSE 373 Data Structures and Algorithms
Data Structures – LECTURE 13 Minumum spanning trees
Chapter 11 Graphs.
CSE 373 Data Structures Lecture 16
Minimum Spanning Trees
CSE 373: Data Structures and Algorithms
Introduction to Algorithms: Greedy Algorithms (and Graphs)
CSE 373: Data Structures and Algorithms
Lecture 12 Algorithm Analysis
CSE 373: Data Structures and Algorithms
CSE 332: Minimum Spanning Trees
Lecture 10 Graph Algorithms
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

CSE 589 Applied Algorithms Course Introduction

CSE Lecture 1 - Spring Instructors Instructor –Richard Ladner – TA –Saurabh Sinha –

CSE Lecture 1 - Spring Resources 589 Course Web Page – Papers and Sections from Books Recommended Algorithms Book –Introduction to Algorithms by Cormen, Leiserson, and Rivest

CSE Lecture 1 - Spring Engagement by Students Weekly Assignments –Algorithm design and evaluation Project with a written report –Evaluate several alternative approaches to algorithmically solve a problem –Must include readings from literature –May include an implementation study –May be done in small teams

CSE Lecture 1 - Spring Final Exam and Grading Thursday, June 10th, 6:30 - 8:20 pm Percentages –Weekly Assignments 30% –Project 30% –Final 40%

CSE Lecture 1 - Spring Some Topics Network spanning tree (warm up) Cache conscious sorting Data Compression Computational Biology Computational Geometry

CSE Lecture 1 - Spring Along the Way Analysis of algorithms Data structures NP-completeness Dynamic programming Greedy algorithms Clustering algorithms Branch-and-bound algorithms Approximation algorithms Classics of algorithms

CSE Lecture 1 - Spring What We’ll Do Today Applied Algorithms - By example Broadcasting in a network Depth First Search Breadth First Search Minimum Spanning Tree

CSE Lecture 1 - Spring Applied Algorithm Scenario Real world problem Abstractly model the problem Find abstract algorithm Adapt to original problem

CSE Lecture 1 - Spring Modeling What kind of algorithm is needed –Sorting or Searching –Graph Problem –Linear Programming –Dynamic Programming –Clustering –Algebra Can I find an algorithm or do I have to invent one

CSE Lecture 1 - Spring Broadcasting in a Network Network of Routers –Organize the routers to efficiently broadcast messages to each other Incoming message Duplicate and send to some neighbors. Eventually all routers get the message

CSE Lecture 1 - Spring Spanning Tree in a Graph Vertex = router Edge = link between routers Spanning tree - Connects all the vertices - No cycles

CSE Lecture 1 - Spring Undirected Graph G = (V,E) –V is a set of vertices (or nodes) –E is a set of unordered pairs of vertices V = {1,2,3,4,5,6,7} E = {{1,2},{1,6},{1,5},{2,7},{2,3}, {3,4},{4,7},{4,5},{5,6}} 2 and 3 are adjacent 2 is incident to edge {2,3}

CSE Lecture 1 - Spring Spanning Tree Problem Input: An undirected graph G = (V,E). G is connected. Output: T contained in E such that –(V,T) is a connected graph –(V,T) has no cycles

CSE Lecture 1 - Spring Depth First Search Algorithm Recursive marking algorithm Initially every vertex is unmarked DFS(i: vertex) mark i; for each j adjacent to i do if j is unmarked then DFS(j) end{DFS}

CSE Lecture 1 - Spring Example of Depth First Search DFS(1)

CSE Lecture 1 - Spring Example Step DFS(1) DFS(2)

CSE Lecture 1 - Spring Example Step DFS(1) DFS(2) DFS(7)

CSE Lecture 1 - Spring Example Step DFS(1) DFS(2) DFS(7) DFS(5)

CSE Lecture 1 - Spring Example Step DFS(1) DFS(2) DFS(7) DFS(5) DFS(4)

CSE Lecture 1 - Spring Example Step DFS(1) DFS(2) DFS(7) DFS(5) DFS(4) DFS(3)

CSE Lecture 1 - Spring Example Step DFS(1) DFS(2) DFS(7) DFS(5) DFS(4) DFS(3) DFS(6) Note that the edges traversed in the depth first search form a spanning tree.

CSE Lecture 1 - Spring Spanning Tree Algorithm ST(i: vertex) mark i; for each j adjacent to i do if j is unmarked then Add {i,j} to T; ST(j); end{ST} Main T := empty set; ST(1); end{Main}

CSE Lecture 1 - Spring Applied Algorithm Scenario Real world problem Abstractly model the problem Find abstract algorithm Adapt to original problem Evaluate Wrong problem Wrong model Incorrect algorithm poor performance

CSE Lecture 1 - Spring Evaluation Step Expanded Algorithm Correct? Choose Data Structure Performance? Implement yes satisfactory no unsatisfactory - New algorithm - New model - New problem - New data structure - New algorithm - New model

CSE Lecture 1 - Spring Correctness of ST Algorithm There are no cycles in T –This is an invariant of the algorithm. –Each edge added to T goes from a vertex in T to a vertex not in T. If G is connected then eventually every vertex is marked. 1 unmarked

CSE Lecture 1 - Spring Correctness (cont.) If G is connected then so is (V,T) i j 1

CSE Lecture 1 - Spring Data Structure Step Algorithm Correct? Choose Data Structure Performance? Implement yes satisfactory no unsatisfactory - New algorithm - New model - New problem - New data structure - New algorithm - New model

CSE Lecture 1 - Spring Edge List and Adjacency Lists List of edges Adjacency lists

CSE Lecture 1 - Spring Adjacency Matrix

CSE Lecture 1 - Spring Data Structure Choice Edge list –Simple but does not support depth first search Adjacency lists –Good for sparse graphs –Supports depth first search Adjacency matrix –Good for dense graphs –Supports depth first search

CSE Lecture 1 - Spring Spanning Tree with Adjacency Lists ST(i: vertex) M[i] := 1; v := G[i]; while not(v = null) j := v.vertex if M[j] = 0 then Add {i,j} to T; ST(j); v := v.next; end{ST} Main G is array of adjacency lists; M[i] := 0 for all i; T is empty; Spanning_Tree(1); end{Main} nextvertex M is the marking array Node of linked list

CSE Lecture 1 - Spring Performance Step Algorithm Correct? Choose Data Structure Performance? Implement yes satisfactory no unsatisfactory - New algorithm - New model - New problem - New data structure - New algorithm - New model

CSE Lecture 1 - Spring Performance of ST Algorithm n vertices and m edges Connected graph Storage complexity O(m) Time complexity O(m)

CSE Lecture 1 - Spring Other Uses of Depth First Search Popularized by Hopcroft and Tarjan 1973 Connected components Biconnected components Strongly connected components in directed graphs topological sorting of a acyclic directed graphs

CSE Lecture 1 - Spring ST using Breadth First Search 1 Uses a queue to order search Queue = 1

CSE Lecture 1 - Spring Breadth First Search Queue = 2,6,5

CSE Lecture 1 - Spring Breadth First Search Queue = 6,5,7,3

CSE Lecture 1 - Spring Breadth First Search Queue = 5,7,3

CSE Lecture 1 - Spring Breadth First Search Queue = 7,3,4

CSE Lecture 1 - Spring Breadth First Search Queue = 3,4

CSE Lecture 1 - Spring Breadth First Search Queue = 4

CSE Lecture 1 - Spring Breadth First Search Queue =

CSE Lecture 1 - Spring Spanning Tree using Breadth First Search Initialize T to be empty; Initialize Q to be empty; Enqueue(1,Q) and mark 1; while Q is not empty do i := Dequeue(Q); for each j adjacent to i do if j is not marked then add {i,j} to T; Enqueue(j,Q) and mark j

CSE Lecture 1 - Spring Best Spanning Tree Each edge has the probability that it won’t fail Find the spanning tree that is least likely to fail

CSE Lecture 1 - Spring Example of a Spanning Tree Probability of success =.85 x.95 x.89 x.95 x 1.0 x.84 =.5735

CSE Lecture 1 - Spring Minimum Spanning Tree Problem Input: Undirected Graph G = (V,E) and a cost function C from E to the reals. C(e) is the cost of edge e. Output: A spanning tree T with minimum total cost. That is: T that minimizes

CSE Lecture 1 - Spring Reducing Best to Minimum Let P(e) be the probability that an edge doesn’t fail. Define: Minimizing is equivalent to maximizing because

CSE Lecture 1 - Spring Example of Reduction Best Spanning Tree ProblemMinimum Spanning Tree Problem

CSE Lecture 1 - Spring Minimum Spanning Tree Boruvka 1926 Kruskal 1956 Prim 1957 also by Jarnik 1930 Karger, Klein, Tarjan 1995 –Randomized linear time algorithm –Probably not practical, but very interesting

CSE Lecture 1 - Spring MST Optimality Principle G = (V,E) with costs C. G connected. Let (V,A) be a subgraph of G that is contained in a minimum spanning tree. Let U be a set such that no edge in A has one end in U and one end in V-U. Let C({u,v}) minimal and u in U and v in V. Let A’ be A with {u,v} added. Then (V,A’) is contained in a minimum spanning tree.

CSE Lecture 1 - Spring Proof of Optimality Principle 1 U V-U u v C({u,v}} is minimal A

CSE Lecture 1 - Spring Proof of Optimality Principle 2 U V-U u v C({u,v}} is minimal C({u,v}) < C({x,y}) x y T

CSE Lecture 1 - Spring Proof of Optimality Principle 3 U V-U u v x y T’ T’ is also a minimum spanning tree C(T’) = C(T) + C({u,v}) - C({x,y}) C(T’) < C(T) A’

CSE Lecture 1 - Spring Kruskal’s Greedy Algorithm Sort the edges by increasing cost; Initialize A to be empty; For each edge e chosen in increasing order do if adding e does not form a cycle then add e to A Invariant: A is always contained in some minimum spanning tree

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring Example of Kruskal 8, {7,4} {2,1} {7,5} {5,6} {5,4} {1,6} {2,7} {2,3} {3,4} {1,5}

CSE Lecture 1 - Spring To Come on Spanning Trees Data Structures for Kruskal Disjoint Union / Find Amortized Analysis of Algorithms Other MST Algorithms