Shortest Paths. Dijkstra's algorithm implementation negative weights. Google maps. Shortest paths in a weighted digraph. Shortest path versions

Size: px
Start display at page:

Download "Shortest Paths. Dijkstra's algorithm implementation negative weights. Google maps. Shortest paths in a weighted digraph. Shortest path versions"

Transcription

1 Google map Shortet Path Dijktra' algorithm implementation negatie eight Reference: Algorithm in Jaa, Chapter Algorithm in Jaa, th Edition Robert Sedgeick and Kein Wayne Copyright 8 Noember, 8 :: PM Shortet path in a eighted digraph Shortet path erion Gien a eighted digraph G, find the hortet directed path from to t Which ertice? From one ertex to another. From one ertex to eery other. Beteen all pair of ertice. Edge eight. Nonnegatie eight. Arbitrary eight. Euclidean eight. t hortet path: t cot: =

2 Early hitory of hortet path algorithm Shortet path application Shimbel (9). Information netork. Ford (9). RAND, economic of tranportation. Leyzorek, Gray, Johnon, Lade, Meaker, Petry, Seitz (97). Combat Deelopment Dept. of the Army Electronic Proing Ground. Dantzig (98). Simplex method for linear programming. Bellman (98). Dynamic programming. Moore (99). Routing long-ditance telephone call for Bell Lab. Dijktra (99). Simpler and fater erion of Ford' algorithm. Map. Robot naigation. Texture mapping. Typeetting in TeX. Urban traffic planning. Optimal pipelining of VLSI chip. Telemarketer operator cheduling. Subroutine in adanced algorithm. Routing of telecommunication meage. Approximating pieceie linear function. Netork routing protocol (OSPF, BGP, RIP). Exploiting arbitrage opportunitie in currency exchange. Optimal truck routing through gien traffic congetion pattern. Reference: Netork Flo: Theory, Algorithm, and Application, R. K. Ahuja, T. L. Magnanti, and J. B. Orlin, Prentice Hall, 99. Edger W. Dijktra: elect quote The quetion of hether computer can think i like the quetion of hether ubmarine can im. Do only hat only you can do. Dijktra' algorithm implementation negatie eight In their capacity a a tool, computer ill be but a ripple on the urface of our culture. In their capacity a intellectual challenge, they are ithout precedent in the cultural hitory of mankind. The ue of COBOL cripple the mind; it teaching hould, therefore, be regarded a a criminal offence. Edger Dijktra Turing aard 97 APL i a mitake, carried through to perfection. It i the language of the future for the programming technique of the pat: it create a ne generation of coding bum. 7 8

3 Single-ource hortet-path Edge relaxation Gien. Weighted digraph G, ource ertex. Goal. Find hortet path from to eery other ertex. Oberation. Ue parent-link repreentation to tore hortet path tree dit[] 9 pred[] - Relaxation along edge e from to. dit[] i length of ome path from to. dit[] i length of ome path from to. If gie a horter path to through, update dit[] and pred[]. dit[] = dit[] = dit[] = 7 int = e.from(), = e.to(); if (dit[] > dit[] + e.eight()) dit[] = dit[] + e.eight()); pred[] = e; 9 Dijktra' algorithm Dijktra' algorithm Initialize S to, dit[] to, dit[] to for all other. Repeat until S contain all ertice connected to : - find edge e ith in S and not in S that minimize dit[] + e.eight(). - relax along edge e - add to S Initialize S to, dit[] to, dit[] to for all other. Repeat until S contain all ertice connected to : - find edge e ith in S and not in S that minimize dit[] + e.eight(). - relax along edge e - add to S dit[] = dit[] + e.eight(); pred[] = e; dit[] e dit[] e S S

4 Dijktra algorithm example Dijktra' algorithm: correctne proof edge ith in S and not in S edge in hortet path tree Inariant. For in S, dit[] i the length of the hortet path from to. (.9) (.) (.) (. =.9 +.) (.8 =.9 +.9) (.) (.7 =. +.) (.9 =. +.) Pf. (by induction on S ) Let be next ertex added to S. Let P* be the path through. Conider any other path P, and let x be firt node on path outide S. P i already longer than P* a oon a it reache x by greedy choice. Thu, dit[] i the length of the hortet path from to. P x S P* (.8 =. +.) (.8 =. +.) (.9) (.8) (. =.8 +.) Shortet path tree Remark. Dijktra examine ertice in increaing ditance from ource. % % Dijktra' algorithm implementation negatie eight 7% %

5 Weighted directed graph API Weighted digraph: adjacency-et implementation in Jaa public cla DirectedEdge implement Comparable<Edge> DirectedEdge(int, int, double eight) create a eighted edge int from() ertex public cla WeightedDigraph priate final int V; priate final SET<Edge>[] adj; int to() ertex double eight() the eight String tostring() tring repreentation public WeightedDigraph(int V) thi.v = V; adj = (SET<DirectedEdge>[]) ne SET[V]; for (int = ; < V; ++) adj[] = ne SET<DirectedEdge>(); public cla WeightedDigraph eighted digraph data type WeightedDigraph(int V) create an empty digraph ith V ertice WeightedDigraph(In in) create a digraph from input tream oid inert(directededge e) add an edge from to public oid addedge(directededge e) int = e.from(); adj[].add(e); ame a eighted undirected graph, but only add edge to ' adjacency et Iterable<DirectedEdge> adj(int ) return an iterator oer edge leaing public Iterable<DirectedEdge> adj(int ) return adj[]; int V() return number of ertice String tostring() return a tring repreentation 7 8 Weighted directed edge: implementation in Jaa Shortet path data type public cla DirectedEdge implement Comparable<DirectedEdge> priate final int, ; priate final double eight; public DirectedEdge(int, int, double eight) thi. = ; thi. = ; thi.eight = eight; public int from() return ; public int to() return ; public int eight() return eight; ame a Edge, except from() and to() replace either() and other() Deign pattern. Dijktra cla i a WeightedDigraph client. Client query method return ditance and path iterator. public cla Dijktra Dijktra(WeightedDigraph G, int ) double ditance(int ) Iterable <DirectedEdge> path(int ) hortet path from in graph G length of hortet path from to hortet path from to public int compareto(edge that) if (thi. < that.) return -; if (thi. > that.) return +; if (thi. < that.) return -; if (thi. > that.) return +; return ; for ue in a ymbol table In = ne In("netork.txt"); WeightedDigraph G = ne WeightedDigraph(in); int =, t = G.V() - ; Dijktra dijktra = ne Dijktra(G, ); StdOut.println("ditance = " + dijktra.ditance(t)); for (int : dijktra.path(t)) StdOut.println(); 9

6 Dijktra implementation challenge Dijktra' algorithm implementation Find edge e ith in S and not in S that minimize dit[] + e.eight(). Ho difficult? Intractable. O(E) time. O(V) time. O(log V) time. O(log* V) time. Contant time. try all edge Dijktra ith an array priority queue Dijktra ith a binary heap Q. What goe onto the priority queue? A. Fringe ertice connected by a ingle edge to a ertex in S (priority = hortet path to lat ertex in S + eight of ingle edge) S dit[] e S Starting to look familiar? Dijktra' algorithm: PQ implementation approach Lazy Dijktra algorithm example Maintain thee inariant. For in S, dit[] i the length of the hortet path from to. For not in S, dit[] minimize dit[] + e.eight() among all edge e ith in S. PQ contain ertice not in S, ith dit[] a priority. Implication. To find next ertex to add to S, delmin from PQ. To maintain inariant, update dit[] by relaxing all edge leaing (and update PQ if ertex not in S get cloer to a ertex in S) (.9) (.) priority queue (.) (. =.9 +.) (.8 =.9 +.9) (.) (.7 =. +.) (.9 =. +.) Total running time. Depend on PQ implementation. Exactly V delmin() operation. Exactly E edge relaxation. At mot inert() operation. (.7) (.8 =. +.) (.8 =. +.) (.9) (.8) (. =.8 +.) (.9) (.9) (. =.8 +.8) (.9 =.8 +.) (.)

7 Lazy implementation of Dijktra' SPT algorithm Dijktra' algorithm: hich priority queue? Initialize dit[] = and marked[] = fale for all ertice. Running time of Dijktra depend on PQ implementation. MinPQplu<Double, Integer> pq = ne MinPQplu<Double, Integer>(); dit[] =.; pq.put(dit[], ); hile (!pq.iempty()) int = pq.delmin(); if (marked[]) continue; marked() = true; for (Edge e : G.adj()) int = e.to(); if (dit[] > dit[] + e.eight()) dit[] = dit[] + e.eight(); pred[] = e; pq.inert(dit[], ); Remark. Same a LazyPrim except dit[] i ditance from to. relax edge e PQ implementation inert delmin total array V V binary heap log V log V E log V d-ay heap (Johnon) log d V log d V E log d V Fibonacci heap (Sleator-Tarjan) log V E + V log V Bottom line. Array implementation optimal for dene graph. Binary heap far better for pare graph. d-ay heap orth the trouble in performance-critical ituation. Fibonacci heap bet in theory, but not orth implementing. Priority-firt earch Inight. All of our graph-earch method are the ame algorithm! Maintain a et of explored ertice S. Gro S by exploring edge ith exactly one endpoint leaing S. DFS. Take edge from ertex hich a dicoered mot recently. BFS. Take from ertex hich a dicoered leat recently. Prim. Take edge of minimum eight. Dijktra. Take edge to ertex that i cloet to. e dit[] S Dijktra' algorithm implementation negatie eight Challenge. Expre thi inight in reuable Jaa code. 7 8

8 Currency conerion Currency conerion Problem. Gien currencie and exchange rate, hat i bet ay to conert one ounce of gold to US dollar? oz. gold $7.. oz. gold 8. $7.. oz. gold. Franc.9 Euro $7.8. [ 8..7 ] [ ] Graph formulation. Vertex = currency. Edge = tranaction, ith eight equal to exchange rate. Find path that maximize product of eight. 7. currency Euro Franc $ Gold G. $ UK pound Euro Japanee Yen Si Franc US dollar F.77 E 9. Gold (oz.) Challenge. Expre a a hortet path problem. 9 Currency conerion Shortet path ith negatie eight: failed attempt Reduce to hortet path problem by taking log. Let eight of edge be - lg (exchange rate from currency to ). Multiplication turn to addition. Shortet path ith gien eight correpond to bet exchange equence. 7. Dijktra. Doen t ork ith negatie edge eight. Dijktra elect ertex immediately after. But hortet path from to i. G. $ lg(.) = Re-eighting. Add a contant to eery edge eight alo doen t ork. 9. Adding 9 to each edge change the hortet path becaue it add 9 to each edge;.9 F.77 E.87 rong thing to do for path ith many edge. Challenge. Sole hortet path problem ith negatie eight. Bad ne. Need a different algorithm.

9 Negatie cycle Shortet path ith negatie eight Def. A negatie cycle i a directed cycle hoe um of edge eight i negatie. Problem. Doe a gien digraph contain a negatie cycle? Problem. Find the hortet imple path from to t C cot(c) < t Oberation. If negatie cycle C i on a path from to t, then hortet path can be made arbitrarily negatie by pinning around cycle. Bad ne. Problem i intractable. C cot(c) < t Good ne. Can ole problem in O(VE) tep; if no negatie cycle, can ole problem ith ame algorithm! Wore ne. Need a different problem. Edge relaxation Shortet path ith negatie eight: dynamic programming algorithm Relaxation along edge e from to. dit[] i length of ome path from to. dit[] i length of ome path from to. If gie a horter path to through, update dit[] and pred[]. A imple olution that ork! Initialize dit[] =, dit[]=. Repeat V time: relax each edge e. dit[] = dit[] = dit[] = 7 int = e.from(), = e.to(); if (dit[] > dit[] + e.eight()) dit[] = dit[] + e.eight()); pred[] = e; for (int i = ; i <= G.V(); i++) for (int = ; < G.V(); ++) for (Edge e : G.adj()) int = e.to(); if (dit[] > dit[] + e.eight()) dit[] = dit[] + e.eight()) pred[] = e; phae i relax edge -

10 Dynamic programming algorithm trace Dynamic programming algorithm dit[].9. (. = +.) (. = +.) relaxed edge that update dit[] (.9 =. +.) (.7 =. +.) (. =.9 +.) Running time. Proportional to E V. Inariant. At end of phae i, dit[] length of any path from to uing at mot i edge. Propoition. If there are no negatie cycle, upon termination dit[] i the length of the hortet path from from to. and pred[] gie the hortet path can top early ince no entrie in dit[] updated (. =.8 +.) (.8 =. +.) (.8 =. +.) 7 8 Bellman-Ford-Moore algorithm Single ource hortet path implementation: cot ummary Oberation. If dit[] doen't change during phae i, no need to relax any edge leaing in phae i+. FIFO implementation. Maintain queue of ertice hoe ditance changed. Running time. Proportional to EV in ort cae. Much fater than that in practice. be careful to keep at mot one copy of each ertex on queue nonnegatie cot no negatie cycle algorithm ort cae typical cae Dijktra (array heap) V V Dijktra (binary heap) E lg V E dynamic programming E V E V Bellman-Ford E V E Remark. Negatie eight make the problem harder. Remark. Negatie cycle make the problem intractable. 9

11 Shortet path application: arbitrage Negatie cycle detection I there an arbitrage opportunity in currency graph? Ex: $.9 Franc.98 Euro $.8. I there a negatie cot cycle? If there i a negatie cycle reachable from. Bellman-Ford-Moore get tuck in loop, updating ertice in cycle. 7. G. $ pred[] F.77 E < Finding a negatie cycle. If any ertex i updated in phae V, there exit a negatie cycle, and e can trace back pred[] to find it. Remark. Fatet algorithm i aluable! Negatie cycle detection Shortet path ummary Goal. Identify a negatie cycle (reachable from any ertex). -8. Dijktra algorithm. Eay and optimal for dene digraph. PQ yield near optimal for pare graph G $ -..9 Priority-firt earch. Generalization of Dijktra algorithm. Encompae DFS, BFS, and Prim. Enable eay olution to many graph-proceing problem. -. F.87 E -7.7 Negatie eight. Arie in application. If negatie cycle, problem i intractable (!) If no negatie cycle, olable ia claic algorithm. Solution. Initialize Bellman-Ford by etting dit[] = for all ertice. Shortet-path i a broadly ueful problem-oling model.

4.4 Shortest Paths. Dijkstra's algorithm implementation acyclic networks negative weights. Google maps. Shortest path versions

4.4 Shortest Paths. Dijkstra's algorithm implementation acyclic networks negative weights. Google maps. Shortest path versions . Shortet Path Google map Dijktra' algorithm implementation acyclic netork negatie eight Reference: Algorithm in Jaa, th edition, Section. Algorithm in Jaa, th Edition Robert Sedgeick and Kein Wayne Copyright

More information

4.4 Shortest Paths. Dijkstra's algorithm implementation acyclic networks negative weights. Reference: Algorithms in Java, 4 th edition, Section 4.

4.4 Shortest Paths. Dijkstra's algorithm implementation acyclic networks negative weights. Reference: Algorithms in Java, 4 th edition, Section 4. 4.4 Shortest Paths Dijkstra's algorithm implementation acyclic networks negative weights Reference: Algorithms in Java, 4 th edition, Section 4.4 Algorithms in Java, 4 th Edition Robert Sedgewick and Kevin

More information

Algorithms. Algorithms 4.4 S HORTEST P ATHS. APIs shortest-paths properties. Dijkstra's algorithm edge-weighted DAGs negative weights

Algorithms. Algorithms 4.4 S HORTEST P ATHS. APIs shortest-paths properties. Dijkstra's algorithm edge-weighted DAGs negative weights Algorithm Shortet path in an edge-weighted digraph R OBERT S EDGEWICK K EVIN W AYNE Given an edge-weighted digraph, find the hortet path from to t. edge-weighted digraph ->. ->. ->7.7 ->7.28 7->.28 ->.2

More information

Algorithms. Algorithms 4.4 SHORTEST PATHS. APIs properties Bellman Ford algorithm Dijkstra s algorithm ROBERT SEDGEWICK KEVIN WAYNE

Algorithms. Algorithms 4.4 SHORTEST PATHS. APIs properties Bellman Ford algorithm Dijkstra s algorithm ROBERT SEDGEWICK KEVIN WAYNE Algorithms ROBERT SEDGEWICK KEVIN WAYNE 4.4 SHORTEST PATHS Algorithms F O U R T H E D I T I O N APIs properties Bellman Ford algorithm Dijkstra s algorithm ROBERT SEDGEWICK KEVIN WAYNE https://algs4.cs.princeton.edu

More information

Shortest Paths Problem. CS 362, Lecture 20. Today s Outline. Negative Weights

Shortest Paths Problem. CS 362, Lecture 20. Today s Outline. Negative Weights Shortet Path Problem CS 6, Lecture Jared Saia Univerity of New Mexico Another intereting problem for graph i that of finding hortet path Aume we are given a weighted directed graph G = (V, E) with two

More information

Today s Outline. CS 561, Lecture 23. Negative Weights. Shortest Paths Problem. The presence of a negative cycle might mean that there is

Today s Outline. CS 561, Lecture 23. Negative Weights. Shortest Paths Problem. The presence of a negative cycle might mean that there is Today Outline CS 56, Lecture Jared Saia Univerity of New Mexico The path that can be trodden i not the enduring and unchanging Path. The name that can be named i not the enduring and unchanging Name. -

More information

Lecture 14: Minimum Spanning Tree I

Lecture 14: Minimum Spanning Tree I COMPSCI 0: Deign and Analyi of Algorithm October 4, 07 Lecture 4: Minimum Spanning Tree I Lecturer: Rong Ge Scribe: Fred Zhang Overview Thi lecture we finih our dicuion of the hortet path problem and introduce

More information

Generic Traverse. CS 362, Lecture 19. DFS and BFS. Today s Outline

Generic Traverse. CS 362, Lecture 19. DFS and BFS. Today s Outline Generic Travere CS 62, Lecture 9 Jared Saia Univerity of New Mexico Travere(){ put (nil,) in bag; while (the bag i not empty){ take ome edge (p,v) from the bag if (v i unmarked) mark v; parent(v) = p;

More information

Contents. shortest paths. Notation. Shortest path problem. Applications. Algorithms and Networks 2010/2011. In the entire course:

Contents. shortest paths. Notation. Shortest path problem. Applications. Algorithms and Networks 2010/2011. In the entire course: Content Shortet path Algorithm and Network 21/211 The hortet path problem: Statement Verion Application Algorithm (for ingle ource p problem) Reminder: relaxation, Dijktra, Variant of Dijktra, Bellman-Ford,

More information

Today s Outline. CS 362, Lecture 19. DFS and BFS. Generic Traverse. BFS and DFS Wrapup Shortest Paths. Jared Saia University of New Mexico

Today s Outline. CS 362, Lecture 19. DFS and BFS. Generic Traverse. BFS and DFS Wrapup Shortest Paths. Jared Saia University of New Mexico Today Outline CS 362, Lecture 9 Jared Saia Univerity of New Mexico BFS and DFS Wrapup Shortet Path Generic Travere DFS and BFS Travere(){ put (nil,) in bag; while (the bag i not empty){ take ome edge (p,v)

More information

Algorithmic Discrete Mathematics 4. Exercise Sheet

Algorithmic Discrete Mathematics 4. Exercise Sheet Algorithmic Dicrete Mathematic. Exercie Sheet Department of Mathematic SS 0 PD Dr. Ulf Lorenz 0. and. May 0 Dipl.-Math. David Meffert Verion of May, 0 Groupwork Exercie G (Shortet path I) (a) Calculate

More information

Lecture 17: Shortest Paths

Lecture 17: Shortest Paths Lecture 7: Shortet Path CSE 373: Data Structure and Algorithm CSE 373 9 WI - KASEY CHAMPION Adminitrivia How to Ace the Technical Interview Seion today! - 6-8pm - Sieg 34 No BS CS Career Talk Thurday -

More information

Uninformed Search Complexity. Informed Search. Search Revisited. Day 2/3 of Search

Uninformed Search Complexity. Informed Search. Search Revisited. Day 2/3 of Search Informed Search ay 2/3 of Search hap. 4, Ruel & Norvig FS IFS US PFS MEM FS IS Uninformed Search omplexity N = Total number of tate = verage number of ucceor (branching factor) L = Length for tart to goal

More information

Robert Bryan and Marshall Dodge, Bert and I and Other Stories from Down East (1961) Michelle Shocked, Arkansas Traveler (1992)

Robert Bryan and Marshall Dodge, Bert and I and Other Stories from Down East (1961) Michelle Shocked, Arkansas Traveler (1992) Well, ya turn left by the fire tation in the village and take the old pot road by the reervoir and...no, that won t do. Bet to continue traight on by the tar road until you reach the choolhoue and then

More information

CS 151. Graph Algorithms. Wednesday, November 28, 12

CS 151. Graph Algorithms. Wednesday, November 28, 12 CS 151 Graph Algorithm 1 Unweighted Shortet Path Problem input: a graph G=(V,E) and a tart vertex goal: determine the length of the hortet path from to every vertex in V (and while you re at it, compute

More information

Graphs: Finding shortest paths

Graphs: Finding shortest paths /0/01 Graph: Finding hortet path Tecniche di Programmazione Summary Definition Floyd-Warhall algorithm Bellman-Ford-Moore algorithm Dijktra algorithm 1 /0/01 Definition Graph: Finding hortet path Definition:

More information

Lecture 18 Graph-Based Algorithms. CSE373: Design and Analysis of Algorithms

Lecture 18 Graph-Based Algorithms. CSE373: Design and Analysis of Algorithms Lecture 18 Graph-Baed Algorithm CSE: Deign and Anali of Algorithm Shortet Path Problem Modeling problem a graph problem: Road map i a weighted graph: vertice = citie edge = road egment between citie edge

More information

8.1 Shortest Path Trees

8.1 Shortest Path Trees I tudy my Bible a I gather apple. Firt I hake the whole tree, that the ripet might fall. Then I climb the tree and hake each limb, and then each branch and then each twig, and then I look under each leaf.

More information

Lecture Outline. Global flow analysis. Global Optimization. Global constant propagation. Liveness analysis. Local Optimization. Global Optimization

Lecture Outline. Global flow analysis. Global Optimization. Global constant propagation. Liveness analysis. Local Optimization. Global Optimization Lecture Outline Global flow analyi Global Optimization Global contant propagation Livene analyi Adapted from Lecture by Prof. Alex Aiken and George Necula (UCB) CS781(Praad) L27OP 1 CS781(Praad) L27OP

More information

Stochastic Search and Graph Techniques for MCM Path Planning Christine D. Piatko, Christopher P. Diehl, Paul McNamee, Cheryl Resch and I-Jeng Wang

Stochastic Search and Graph Techniques for MCM Path Planning Christine D. Piatko, Christopher P. Diehl, Paul McNamee, Cheryl Resch and I-Jeng Wang Stochatic Search and Graph Technique for MCM Path Planning Chritine D. Piatko, Chritopher P. Diehl, Paul McNamee, Cheryl Rech and I-Jeng Wang The John Hopkin Univerity Applied Phyic Laboratory, Laurel,

More information

Shortest Path Problems

Shortest Path Problems Shortet Path Problem How can we find the hortet route between two point on a road map? Model the problem a a graph problem: Road map i a weighted graph: vertice = citie edge = road egment between citie

More information

Delaunay Triangulation: Incremental Construction

Delaunay Triangulation: Incremental Construction Chapter 6 Delaunay Triangulation: Incremental Contruction In the lat lecture, we have learned about the Lawon ip algorithm that compute a Delaunay triangulation of a given n-point et P R 2 with O(n 2 )

More information

UNDIRECTED GRAPHS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING

UNDIRECTED GRAPHS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING BBM - ALGORIHMS DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton Uniersity. Undirected Graphs

More information

7. NETWORK FLOW I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne. Last updated on Sep 8, :40 AM

7. NETWORK FLOW I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne. Last updated on Sep 8, :40 AM 7. NETWORK FLOW I max-flow and min-cut problem Ford-Fulkeron algorithm max-flow min-cut theorem capacity-caling algorithm hortet augmenting path blocking-flow algorithm unit-capacity imple network Lecture

More information

CMSC 132: Object-Oriented Programming II. Shortest Paths

CMSC 132: Object-Oriented Programming II. Shortest Paths CMSC 13: Object-Oriented Programming II Shortest Paths 1 Quiz 1 One advantage of adjacency list representation over adjacency matrix representation of a graph is that in adjacency list representation,

More information

Minimum congestion spanning trees in bipartite and random graphs

Minimum congestion spanning trees in bipartite and random graphs Minimum congetion panning tree in bipartite and random graph M.I. Otrovkii Department of Mathematic and Computer Science St. John Univerity 8000 Utopia Parkway Queen, NY 11439, USA e-mail: otrovm@tjohn.edu

More information

CS 467/567: Divide and Conquer on the PRAM

CS 467/567: Divide and Conquer on the PRAM CS 467/567: Divide and Conquer on the PRAM Stefan D. Bruda Winter 2017 BINARY SEARCH Problem: Given a equence S 1..n orted in nondecreaing order and a value x, find the ubcript k uch that S i x If n proceor

More information

UNDIRECTED GRAPHS TODAY BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING. Undirected graphs. Graph applications

UNDIRECTED GRAPHS TODAY BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING. Undirected graphs. Graph applications BBM - ALGORIHMS ODAY DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS Undirected Graphs Graph API Depth-first search Challenges Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick

More information

1 The secretary problem

1 The secretary problem Thi i new material: if you ee error, pleae email jtyu at tanford dot edu 1 The ecretary problem We will tart by analyzing the expected runtime of an algorithm, a you will be expected to do on your homework.

More information

Lecture 11: Analysis of Algorithms (CS ) 1

Lecture 11: Analysis of Algorithms (CS ) 1 Lecture 11: Analysis of Algorithms (CS583-002) 1 Amarda Shehu November 12, 2014 1 Some material adapted from Kevin Wayne s Algorithm Class @ Princeton 1 2 Dynamic Programming Approach Floyd-Warshall Shortest

More information

Algorithms. Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES

Algorithms. Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES Announcements Algorithms ROBERT SEDGEWICK KEVIN WAYNE Exam Regrades Due by Wednesday s lecture. Teaching Experiment: Dynamic Deadlines (WordNet) Right now, WordNet is due at PM on April 8th. Starting Tuesday

More information

Routing Definition 4.1

Routing Definition 4.1 4 Routing So far, we have only looked at network without dealing with the iue of how to end information in them from one node to another The problem of ending information in a network i known a routing

More information

A SIMPLE IMPERATIVE LANGUAGE THE STORE FUNCTION NON-TERMINATING COMMANDS

A SIMPLE IMPERATIVE LANGUAGE THE STORE FUNCTION NON-TERMINATING COMMANDS A SIMPLE IMPERATIVE LANGUAGE Eventually we will preent the emantic of a full-blown language, with declaration, type and looping. However, there are many complication, o we will build up lowly. Our firt

More information

Topics. Lecture 37: Global Optimization. Issues. A Simple Example: Copy Propagation X := 3 B > 0 Y := 0 X := 4 Y := Z + W A := 2 * 3X

Topics. Lecture 37: Global Optimization. Issues. A Simple Example: Copy Propagation X := 3 B > 0 Y := 0 X := 4 Y := Z + W A := 2 * 3X Lecture 37: Global Optimization [Adapted from note by R. Bodik and G. Necula] Topic Global optimization refer to program optimization that encompa multiple baic block in a function. (I have ued the term

More information

Algorithms 4.3 MINIMUM SPANNING TREES. edge-weighted graph API greedy algorithm Kruskal's algorithm Prim's algorithm advanced topics

Algorithms 4.3 MINIMUM SPANNING TREES. edge-weighted graph API greedy algorithm Kruskal's algorithm Prim's algorithm advanced topics 4.3 MINIMUM SPANNING TREES Algorithms F O U R T H E D I T I O N edge-weighted graph API greedy algorithm Kruskal's algorithm Prim's algorithm advanced topics R O B E R T S E D G E W I C K K E V I N W A

More information

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction greedy algorithm edge-weighted graph API Kruskal's algorithm Prim's algorithm context

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction greedy algorithm edge-weighted graph API Kruskal's algorithm Prim's algorithm context Algorithms ROBERT SEDGEWICK KEVIN WAYNE 4.3 MINIMUM SPANNING TREES Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu introduction greedy algorithm edge-weighted

More information

Shortest path problems

Shortest path problems Next... Shortest path problems Single-source shortest paths in weighted graphs Shortest-Path Problems Properties of Shortest Paths, Relaxation Dijkstra s Algorithm Bellman-Ford Algorithm Shortest-Paths

More information

Announcements. CSE332: Data Abstractions Lecture 19: Parallel Prefix and Sorting. The prefix-sum problem. Outline. Parallel prefix-sum

Announcements. CSE332: Data Abstractions Lecture 19: Parallel Prefix and Sorting. The prefix-sum problem. Outline. Parallel prefix-sum Announcement Homework 6 due Friday Feb 25 th at the BEGINNING o lecture CSE332: Data Abtraction Lecture 19: Parallel Preix and Sorting Project 3 the lat programming project! Verion 1 & 2 - Tue March 1,

More information

CS201: Data Structures and Algorithms. Assignment 2. Version 1d

CS201: Data Structures and Algorithms. Assignment 2. Version 1d CS201: Data Structure and Algorithm Aignment 2 Introduction Verion 1d You will compare the performance of green binary earch tree veru red-black tree by reading in a corpu of text, toring the word and

More information

Key Terms - MinMin, MaxMin, Sufferage, Task Scheduling, Standard Deviation, Load Balancing.

Key Terms - MinMin, MaxMin, Sufferage, Task Scheduling, Standard Deviation, Load Balancing. Volume 3, Iue 11, November 2013 ISSN: 2277 128X International Journal of Advanced Reearch in Computer Science and Software Engineering Reearch Paper Available online at: www.ijarce.com Tak Aignment in

More information

Exercise 4: Markov Processes, Cellular Automata and Fuzzy Logic

Exercise 4: Markov Processes, Cellular Automata and Fuzzy Logic Exercie 4: Marko rocee, Cellular Automata and Fuzzy Logic Formal Method II, Fall Semeter 203 Solution Sheet Marko rocee Theoretical Exercie. (a) ( point) 0.2 0.7 0.3 tanding 0.25 lying 0.5 0.4 0.2 0.05

More information

CERIAS Tech Report EFFICIENT PARALLEL ALGORITHMS FOR PLANAR st-graphs. by Mikhail J. Atallah, Danny Z. Chen, and Ovidiu Daescu

CERIAS Tech Report EFFICIENT PARALLEL ALGORITHMS FOR PLANAR st-graphs. by Mikhail J. Atallah, Danny Z. Chen, and Ovidiu Daescu CERIAS Tech Report 2003-15 EFFICIENT PARALLEL ALGORITHMS FOR PLANAR t-graphs by Mikhail J. Atallah, Danny Z. Chen, and Ovidiu Daecu Center for Education and Reearch in Information Aurance and Security,

More information

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction cut property edge-weighted graph API Kruskal s algorithm Prim s algorithm

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction cut property edge-weighted graph API Kruskal s algorithm Prim s algorithm Algorithms ROBERT SEDGEWICK KEVIN WAYNE 4.3 MINIMUM SPANNING TREES Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE introduction cut property edge-weighted graph API Kruskal s algorithm

More information

Chapter 7 Packet-Switching Networks. Chapter 7 Packet-Switching Networks. Packet Switching. Network Layer. Network Service

Chapter 7 Packet-Switching Networks. Chapter 7 Packet-Switching Networks. Packet Switching. Network Layer. Network Service Chapter 7 Packet-Switching etwork etwork Operation & Topology Datagram and Virtual Circuit Structure of a Packet Switch Routing in Packet etwork Shortet Path Routing etwork Chapter 7 Packet-Switching etwork

More information

AVL Tree. The height of the BST be as small as possible

AVL Tree. The height of the BST be as small as possible 1 AVL Tree re and Algorithm The height of the BST be a mall a poible The firt balanced BST. Alo called height-balanced tree. Introduced by Adel on-vel kii and Landi in 1962. BST with the following condition:

More information

Advanced Encryption Standard and Modes of Operation

Advanced Encryption Standard and Modes of Operation Advanced Encryption Standard and Mode of Operation G. Bertoni L. Breveglieri Foundation of Cryptography - AES pp. 1 / 50 AES Advanced Encryption Standard (AES) i a ymmetric cryptographic algorithm AES

More information

Midterm 2 March 10, 2014 Name: NetID: # Total Score

Midterm 2 March 10, 2014 Name: NetID: # Total Score CS 3 : Algorithm and Model of Computation, Spring 0 Midterm March 0, 0 Name: NetID: # 3 Total Score Max 0 0 0 0 Grader Don t panic! Pleae print your name and your NetID in the boxe above. Thi i a cloed-book,

More information

Representations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs

Representations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs Representations of Weighted Graphs (as Matrices) A B Algorithms and Data Structures: Minimum Spanning Trees 9.0 F 1.0 6.0 5.0 6.0 G 5.0 I H 3.0 1.0 C 5.0 E 1.0 D 28th Oct, 1st & 4th Nov, 2011 ADS: lects

More information

graph G not connected

graph G not connected Algorithms ROBERT SEDGEWICK KEVIN WAYNE. MINIMUM SPANNING TREES. MINIMUM SPANNING TREES introduction introduction Algorithms F O U R T H E D I T I O N greedy algorithm edge-weighted graph API Kruskal's

More information

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction greedy algorithm edge-weighted graph API Kruskal's algorithm Prim's algorithm context

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction greedy algorithm edge-weighted graph API Kruskal's algorithm Prim's algorithm context Algorithms ROBERT SEDGEWICK KEVIN WAYNE 4.3 MINIMUM SPANNING TREES Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu introduction greedy algorithm edge-weighted

More information

Karen L. Collins. Wesleyan University. Middletown, CT and. Mark Hovey MIT. Cambridge, MA Abstract

Karen L. Collins. Wesleyan University. Middletown, CT and. Mark Hovey MIT. Cambridge, MA Abstract Mot Graph are Edge-Cordial Karen L. Collin Dept. of Mathematic Weleyan Univerity Middletown, CT 6457 and Mark Hovey Dept. of Mathematic MIT Cambridge, MA 239 Abtract We extend the definition of edge-cordial

More information

6.4 Maximum Flow. overview Ford-Fulkerson implementations applications

6.4 Maximum Flow. overview Ford-Fulkerson implementations applications 6.4 Maximum Flow overview Ford-Fulkerson implementations applications Algorithms, 4 th Edition Robert Sedgewick and Kevin Wayne Copyright 2002 2010 April 18, 2011 11:02:27 AM Mincut problem Given. A weighted

More information

UNDIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING

UNDIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton Uniersity. BBM DAA SRUCURES DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS Undirected Graphs

More information

Laboratory Exercise 6

Laboratory Exercise 6 Laboratory Exercie 6 Adder, Subtractor, and Multiplier The purpoe of thi exercie i to examine arithmetic circuit that add, ubtract, and multiply number. Each type of circuit will be implemented in two

More information

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction cut property edge-weighted graph API Kruskal s algorithm Prim s algorithm context

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction cut property edge-weighted graph API Kruskal s algorithm Prim s algorithm context Algorithms ROBERT SEDGEWICK KEVIN WAYNE 4.3 MINIMUM SPANNING TREES Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu introduction cut property edge-weighted

More information

Algorithms. Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES

Algorithms. Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES Algorithms ROBERT SEDGEWICK KEVIN WAYNE. MINIMUM SPANNING TREES. MINIMUM SPANNING TREES Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE http://algs.cs.princeton.edu introduction greedy

More information

Laboratory Exercise 6

Laboratory Exercise 6 Laboratory Exercie 6 Adder, Subtractor, and Multiplier a a The purpoe of thi exercie i to examine arithmetic circuit that add, ubtract, and multiply number. Each b c circuit will be decribed in Verilog

More information

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction greedy algorithm edge-weighted graph API Kruskal's algorithm Prim's algorithm context

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction greedy algorithm edge-weighted graph API Kruskal's algorithm Prim's algorithm context Algorithms ROBERT SEDGEWICK KEVIN WAYNE 4.3 MINIMUM SPANNING TREES Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu introduction greedy algorithm edge-weighted

More information

CORRECTNESS ISSUES AND LOOP INVARIANTS

CORRECTNESS ISSUES AND LOOP INVARIANTS The next everal lecture 2 Study algorithm for earching and orting array. Invetigate their complexity how much time and pace they take Formalize the notion of average-cae and wort-cae complexity CORRECTNESS

More information

Parity-constrained Triangulations with Steiner points

Parity-constrained Triangulations with Steiner points Parity-contrained Triangulation with Steiner point Victor Alarez October 31, 2012 Abtract Let P R 2 be a et of n point, of which k lie in the interior of the conex hull CH(P) of P. Let u call a triangulation

More information

ECE250: Algorithms and Data Structures Single Source Shortest Paths Dijkstra s Algorithm

ECE250: Algorithms and Data Structures Single Source Shortest Paths Dijkstra s Algorithm ECE0: Algorithms and Data Strctres Single Sorce Shortest Paths Dijkstra s Algorithm Ladan Tahildari, PEng, SMIEEE Associate Professor Software Technologies Applied Research (STAR) Grop Dept. of Elect.

More information

How to. write a paper. The basics writing a solid paper Different communities/different standards Common errors

How to. write a paper. The basics writing a solid paper Different communities/different standards Common errors How to write a paper The baic writing a olid paper Different communitie/different tandard Common error Reource Raibert eay My grammar point Article on a v. the Bug in writing Clarity Goal Conciene Calling

More information

Brief Announcement: Distributed 3/2-Approximation of the Diameter

Brief Announcement: Distributed 3/2-Approximation of the Diameter Brief Announcement: Ditributed /2-Approximation of the Diameter Preliminary verion of a brief announcement to appear at DISC 14 Stephan Holzer MIT holzer@mit.edu David Peleg Weizmann Intitute david.peleg@weizmann.ac.il

More information

A note on degenerate and spectrally degenerate graphs

A note on degenerate and spectrally degenerate graphs A note on degenerate and pectrally degenerate graph Noga Alon Abtract A graph G i called pectrally d-degenerate if the larget eigenvalue of each ubgraph of it with maximum degree D i at mot dd. We prove

More information

Partha Sarathi Manal

Partha Sarathi Manal MA 515: Introduction to Algorithms & MA5 : Design and Analysis of Algorithms [-0-0-6] Lecture 20 & 21 http://www.iitg.ernet.in/psm/indexing_ma5/y09/index.html Partha Sarathi Manal psm@iitg.ernet.in Dept.

More information

See chapter 8 in the textbook. Dr Muhammad Al Salamah, Industrial Engineering, KFUPM

See chapter 8 in the textbook. Dr Muhammad Al Salamah, Industrial Engineering, KFUPM Goal programming Objective of the topic: Indentify indutrial baed ituation where two or more objective function are required. Write a multi objective function model dla a goal LP Ue weighting um and preemptive

More information

Laboratory Exercise 6

Laboratory Exercise 6 Laboratory Exercie 6 Adder, Subtractor, and Multiplier The purpoe of thi exercie i to examine arithmetic circuit that add, ubtract, and multiply number. Each circuit will be decribed in Verilog and implemented

More information

xy-monotone path existence queries in a rectilinear environment

xy-monotone path existence queries in a rectilinear environment CCCG 2012, Charlottetown, P.E.I., Augut 8 10, 2012 xy-monotone path exitence querie in a rectilinear environment Gregory Bint Anil Mahehwari Michiel Smid Abtract Given a planar environment coniting of

More information

Shortest Paths in Directed Graphs

Shortest Paths in Directed Graphs Shortet Path in Direted Graph Jonathan Turner January, 0 Thi note i adapted from Data Struture and Network Algorithm y Tarjan. Let G = (V, E) e a direted graph and let length e a real-valued funtion on

More information

Minimum Spanning Trees My T. UF

Minimum Spanning Trees My T. UF Introduction to Algorithms Minimum Spanning Trees @ UF Problem Find a low cost network connecting a set of locations Any pair of locations are connected There is no cycle Some applications: Communication

More information

Index. stack-based, 400 A* algorithm, 325

Index. stack-based, 400 A* algorithm, 325 Index Abstract transitive closure, 174-175, 217-221 Active vertex, 411 Acyclic graph. See Digraph; Directed acyclic graph (DAG) Acyclic network, 313-321, 334-335 maxflow, 427-429 Adjacency-lists representation,

More information

Localized Minimum Spanning Tree Based Multicast Routing with Energy-Efficient Guaranteed Delivery in Ad Hoc and Sensor Networks

Localized Minimum Spanning Tree Based Multicast Routing with Energy-Efficient Guaranteed Delivery in Ad Hoc and Sensor Networks Localized Minimum Spanning Tree Baed Multicat Routing with Energy-Efficient Guaranteed Delivery in Ad Hoc and Senor Network Hanne Frey Univerity of Paderborn D-3398 Paderborn hanne.frey@uni-paderborn.de

More information

Laboratory Exercise 2

Laboratory Exercise 2 Laoratory Exercie Numer and Diplay Thi i an exercie in deigning cominational circuit that can perform inary-to-decimal numer converion and inary-coded-decimal (BCD) addition. Part I We wih to diplay on

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

else end while End References

else end while End References 621-630. [RM89] [SK76] Roenfeld, A. and Melter, R. A., Digital geometry, The Mathematical Intelligencer, vol. 11, No. 3, 1989, pp. 69-72. Sklanky, J. and Kibler, D. F., A theory of nonuniformly digitized

More information

Greedy Algorithms. At each step in the algorithm, one of several choices can be made.

Greedy Algorithms. At each step in the algorithm, one of several choices can be made. Greedy Algorithms At each step in the algorithm, one of several choices can be made. Greedy Strategy: make the choice that is the best at the moment. After making a choice, we are left with one subproblem

More information

Algorithms and Data Structures: Minimum Spanning Trees I and II - Prim s Algorithm. ADS: lects 14 & 15 slide 1

Algorithms and Data Structures: Minimum Spanning Trees I and II - Prim s Algorithm. ADS: lects 14 & 15 slide 1 Algorithms and Data Structures: Minimum Spanning Trees I and II - Prim s Algorithm ADS: lects 14 & 15 slide 1 Weighted Graphs Definition 1 A weighted (directed or undirected graph) is a pair (G, W ) consisting

More information

Solutions by Artem Gritsenko, Ahmedul Kabir, Yun Lu, and Prof. Ruiz Problem I. By Artem Gritsenko, Yun Lu, and Prof. Ruiz

Solutions by Artem Gritsenko, Ahmedul Kabir, Yun Lu, and Prof. Ruiz Problem I. By Artem Gritsenko, Yun Lu, and Prof. Ruiz CS3 Algorithm. B Term 3. Homework 5 Soltion Soltion b Artem Gritenko, Ahmedl Kabir, Yn L, and Prof. Riz Problem I. B Artem Gritenko, Yn L, and Prof. Riz a. Algorithm. KNAPSACK (,,,,,,, ) # i the knapack

More information

Universität Augsburg. Institut für Informatik. Approximating Optimal Visual Sensor Placement. E. Hörster, R. Lienhart.

Universität Augsburg. Institut für Informatik. Approximating Optimal Visual Sensor Placement. E. Hörster, R. Lienhart. Univerität Augburg à ÊÇÅÍÆ ËÀǼ Approximating Optimal Viual Senor Placement E. Hörter, R. Lienhart Report 2006-01 Januar 2006 Intitut für Informatik D-86135 Augburg Copyright c E. Hörter, R. Lienhart Intitut

More information

Compiler Construction

Compiler Construction Compiler Contruction Lecture 6 - An Introduction to Bottom- Up Paring 3 Robert M. Siegfried All right reerved Bottom-up Paring Bottom-up parer pare a program from the leave of a pare tree, collecting the

More information

Shortest Path Problem

Shortest Path Problem Shortest Path Problem CLRS Chapters 24.1 3, 24.5, 25.2 Shortest path problem Shortest path problem (and variants) Properties of shortest paths Algorithmic framework Bellman-Ford algorithm Shortest paths

More information

Programmazione di sistemi multicore

Programmazione di sistemi multicore Programmazione di itemi multicore A.A. 2015-2016 LECTURE 9 IRENE FINOCCHI http://wwwuer.di.uniroma1.it/~inocchi/ More complex parallel pattern PARALLEL PREFIX PARALLEL SORTING PARALLEL MERGESORT PARALLEL

More information

Fundamental Algorithms CSCI-GA /Summer Solution to Homework 8

Fundamental Algorithms CSCI-GA /Summer Solution to Homework 8 Fundamental Algorithms CSCI-GA.70-00/Summer 206 Solution to Homework 8 Problem (CLRS 23.-6). ( point) Show that a graph has a unique minimum spanning tree if, for every cut of the graph, there is a unique

More information

Homework 4 Due Thursday Oct 7. CLRS 12-4 (number of binary trees) CLRS (rb insert implementation)

Homework 4 Due Thursday Oct 7. CLRS 12-4 (number of binary trees) CLRS (rb insert implementation) Homework 4 Due Thurday Oct 7 CLRS 12-4 (number of binary tree) CLRS 13.3-6 (rb inert imlementation) 1 Chater 13: Red-Black Tree A red-black tree i a node-colored BST. Each node i colored either black or

More information

arxiv: v1 [cs.ds] 27 Feb 2018

arxiv: v1 [cs.ds] 27 Feb 2018 Incremental Strong Connectivity and 2-Connectivity in Directed Graph Louka Georgiadi 1, Giueppe F. Italiano 2, and Niko Parotidi 2 arxiv:1802.10189v1 [c.ds] 27 Feb 2018 1 Univerity of Ioannina, Greece.

More information

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved. Chapter 9 Greedy Technique Copyright 2007 Pearson Addison-Wesley. All rights reserved. Greedy Technique Constructs a solution to an optimization problem piece by piece through a sequence of choices that

More information

Minimum Spanning Trees

Minimum Spanning Trees Minimum Spanning Trees Overview Problem A town has a set of houses and a set of roads. A road connects and only houses. A road connecting houses u and v has a repair cost w(u, v). Goal: Repair enough (and

More information

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 7 Lecturer: David Wagner February 13, Notes 7 for CS 170

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 7 Lecturer: David Wagner February 13, Notes 7 for CS 170 UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 7 Lecturer: David Wagner February 13, 003 Notes 7 for CS 170 1 Dijkstra s Algorithm Suppose each edge (v, w) of our graph has a

More information

Lecture 25 Spanning Trees

Lecture 25 Spanning Trees Lecture 25 Spanning Trees 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning, Iliano Cervesato The following is a simple example of a connected, undirected graph with 5 vertices (A,

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 4 Graphs Definitions Traversals Adam Smith 9/8/10 Exercise How can you simulate an array with two unbounded stacks and a small amount of memory? (Hint: think of a

More information

Recitation 13. Minimum Spanning Trees Announcements. SegmentLab has been released, and is due Friday, November 17. It s worth 135 points.

Recitation 13. Minimum Spanning Trees Announcements. SegmentLab has been released, and is due Friday, November 17. It s worth 135 points. Recitation 13 Minimum Spanning Trees 13.1 Announcements SegmentLab has been released, and is due Friday, November 17. It s worth 135 points. 73 74 RECITATION 13. MINIMUM SPANNING TREES 13.2 Prim s Algorithm

More information

Lecture 8: More Pipelining

Lecture 8: More Pipelining Overview Lecture 8: More Pipelining David Black-Schaffer davidbb@tanford.edu EE8 Spring 00 Getting Started with Lab Jut get a ingle pixel calculating at one time Then look into filling your pipeline Multiplier

More information

6.8 Shortest Paths. Chapter 6. Dynamic Programming. Shortest Paths: Failed Attempts. Shortest Paths

6.8 Shortest Paths. Chapter 6. Dynamic Programming. Shortest Paths: Failed Attempts. Shortest Paths 1 Chaper.8 Shore Pah Dynamic Programming Slide by Kein Wayne. Copyrigh 5 Pearon-Addion Weley. All righ reered. Shore Pah Shore Pah: Failed Aemp Shore pah problem. Gien a direced graph G = (V, E), wih edge

More information

Planning of scooping position and approach path for loading operation by wheel loader

Planning of scooping position and approach path for loading operation by wheel loader 22 nd International Sympoium on Automation and Robotic in Contruction ISARC 25 - September 11-14, 25, Ferrara (Italy) 1 Planning of cooping poition and approach path for loading operation by wheel loader

More information

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI. Department of Computer Science and Engineering CS6301 PROGRAMMING DATA STRUCTURES II

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI. Department of Computer Science and Engineering CS6301 PROGRAMMING DATA STRUCTURES II DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI Department of Computer Science and Engineering CS6301 PROGRAMMING DATA STRUCTURES II Anna University 2 & 16 Mark Questions & Answers Year / Semester: II / III

More information

CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review

CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review 1 Review 1 Something I did not emphasize enough last time is that during the execution of depth-firstsearch, we construct depth-first-search trees. One graph may have multiple depth-firstsearch trees,

More information

Single Source Shortest Path: The Bellman-Ford Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley

Single Source Shortest Path: The Bellman-Ford Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley Single Source Shortest Path: The Bellman-Ford Algorithm Slides based on Kevin Wayne / Pearson-Addison Wesley Single Source Shortest Path Problem Shortest path network. Directed graph G = (V, E, w). Weight

More information

VLSI Design 9. Datapath Design

VLSI Design 9. Datapath Design VLSI Deign 9. Datapath Deign 9. Datapath Deign Lat module: Adder circuit Simple adder Fat addition Thi module omparator Shifter Multi-input Adder Multiplier omparator detector: A = 1 detector: A = 11 111

More information

Operational Semantics Class notes for a lecture given by Mooly Sagiv Tel Aviv University 24/5/2007 By Roy Ganor and Uri Juhasz

Operational Semantics Class notes for a lecture given by Mooly Sagiv Tel Aviv University 24/5/2007 By Roy Ganor and Uri Juhasz Operational emantic Page Operational emantic Cla note for a lecture given by Mooly agiv Tel Aviv Univerity 4/5/7 By Roy Ganor and Uri Juhaz Reference emantic with Application, H. Nielon and F. Nielon,

More information

Graphs. Part II: SP and MST. Laura Toma Algorithms (csci2200), Bowdoin College

Graphs. Part II: SP and MST. Laura Toma Algorithms (csci2200), Bowdoin College Laura Toma Algorithms (csci2200), Bowdoin College Topics Weighted graphs each edge (u, v) has a weight denoted w(u, v) or w uv stored in the adjacency list or adjacency matrix The weight of a path p =

More information