Algorithms and Data Structures (INF1) Lecture 14/15 Hua Lu


 Anastasia Reeves
 1 years ago
 Views:
Transcription
1 Algorithms and Data Structures (INF1) Lecture 14/15 Hua Lu Department of Computer Science Aalborg University Fall 2007
2 This Lecture Shortest paths Problem preliminary Shortest paths in DAG BellmanMoore algorithm Dijkstra s algorithm 2
3 Motivation Example What is the shortest path from Århus to Skagen? Århus > Aalborg > Frederikshavn > Skagen Total cost: 4 hours This example is not so hard to figure out Only 4 possibilities Consider cases with Large number of nodes Multiple edge or path choices between the same pair of cities 1.5 Hjørring Viborg Skagen Aalborg 2 1 Frederikshavn 1 1 Århus 3
4 Shortest Path Problem Given a digraph whose edges are attached with costs, two of its vertices are specified as a and b Find a shortest path from a to b (if there exists one) s.t. the total cost of that path is the minimal This cost is called distance, denoted as d(a, b) Assumptions Edges may have negative costs Cycles with negative cost are not allowed If such a cycle is found, report it and stop the shortest path finding 4
5 Triangle Inequality If v is reachable from u, and w is reachable from v, we have d(u, w) d(u, v) + d(v, w) Proof d(u, v) indicates the shortest path from u to v d(v, w) indicates the shortest path from v to w d(u, v) + d(v, w) indicates one path from u to w A shortest path from u to w must exist, with cost d(u, w) d(u, w) d(u, v) + d(v, w) holds as d(u, w) indicates the shortest path! If = holds, v is on the shortest path from u to w In particular, if there is an edge between v and w, then d(u, w) d(u, v) + c(v, w) 5
6 Shortest Path Spanning Tree Given a digraph G with edge costs, each vertex is reachable from some start vertex a. Then, either G contains a negative cycle, or else it contains a spanning tree T, rooted at a, such that for each vertex v in G, the total cost of the path through T from a to v is equal to d(a, v) T reserves shortest path information Skagen 1 Such a tree is called a shortest path spanning tree E.g., start from Århus Hjørring 1 Aalborg Frederikshavn 1 Vibor g 1 2 Århus 6
7 Single Source Shortest Paths A single start vertex has been specified We call it a single source shortest path problem Three main algorithms exist for such problems Nodes # n, edge # m Topological sorting Dijkstra algorithm BellmanMoore algorithm 7
8 A Simple Recurrence The input digraph can have negative costs, but no negative cycles Still positive cycles possibly! Recurrence like the one we used in critical path d(a, a) = 0 d(a, v) = min{d(a, u) + c(u,v)}, u Pred(v) Pred(v) denotes the set of direct predecessors of v i.e. <u, v> is an edge The recurrence cannot be used due to possible cycles! For d(a, v), v can be involved in a cycle, recursion on v can be forever If G is a DAG, then this recurrence works as the basis for the topological sorting based algorithm of O(n+m) 8
9 BellmanMoore Algorithm d k (a, v) = the cost of a shortest path from a to v among all paths of length at most k Number of edges involved k If no such a path from a to v of length at most k, d k (a, v)= New recurrence d 0 (a, a) = 0 d 0 (a, v) = d k (a, v) = min{d k1 (a, v), min u Pred(v) {d k1 (a, u) + c(u, v)}} BellmanMoore algorithm Repeatedly compute d k (a, v) for k = 0, 1, 2, For a digraph with n nodes, the largest k to consider is n1 9
10 Complexity of BellmanMoore Alg k=0 k=1 k=n1 a=v 1 0 v 2 v n We need to compute this table column by column Dynamic programming! Cost to compute one d k (a, v) is O( Pred(v) ) Cost to compute one column is O(n+m) We have O(n) columns Total cost is O(n (n+m)) in the worst case 10
11 Negative Cycle Detection How to decide whether a digraph has a negative cycle or not? Use BellmanMoore algorithm and calculate also the column k=n The graph has a negative cycle if and only if d n (a, v) < d n1 (a, v) for some vertex v 11
12 Dijkstra s Algorithm Preliminaries Assumption No edge has negative cost Priority queue Like a symbol table, a set of entries Each entry has form of <key, value> Special operations find_min:entry_type Returns the entry in the priority queue whose key is minimum delete_min:entry_type Deletes and returns the entry that would be returned by find_min We use a priority queue when we are more concerned about items with extreme keys than the total order among all keys In shortest path finding, we care about the shortest path so far, not the order of all possible paths w.r.t. their lengths 12
13 Dijkstra s Algorithm Each vertex has fields v.visited, v.parent, v.distance A priority queue q When one vertex v is inserted into q, we regard v.distance as the key and v itself as the value, i.e., <v.distance, v> dijkstra(g:digraph, a:vertex_type) 1. for each vertex v, set v.visited:=false, v.distance:= 2. a.distance:=0; a.visited:=true; a.parent:=nil; q.insert(a) 3. while NOT q.empty do v:=q.delete_min for each edge (v, w) do if NOT w.visited then w.visited:=true; w.parent:=v; w.distance:=v.distance+c(v, w); q.insert(w) else if v.distance+c(v, w) < w.distance then w.distance:=v.distance+c(v, w); w.parent:=v 13
14 Correctness of Dijkstra s Algorithm v a x L: vertices Q: vertices R: removed from Q Loop Invariant z L: z.distance=d(a, z) still in Q z L: each successor of z is either in L or in Q z Q: z.distance is the length of one shortest path from node a to node z via vertices in L Prove it by induction on k, loop iteration vertices not visited yet 14
15 Complexity of Dijkstra s Algorithm Cost of step 1 is O(n) Cost of step 2 is O(1) Cost of step 3 is O(n+m) + time cost on the priority queue delete_min: n times insert: n times distance update: m times Total cost O(n + m + n (T(delete_min)) + n (T(insert)) + m (T(dist_update))) Priority queue implementation Linked list Fibonacci heap delete_min O(n) O(log n) insert O(1) O(1) distance update O(1) O(1) Total time cost O(n 2 ) O(n log n + m) 15
16 Shortest Paths Summary Arbitrary digraphs Use BellmanMoore algorithm O(n (n+m)) O(n 3 ) if m=θ(n 2 ) Digraphs with nonnegative costs Use Dijkstra s algorithm O(n log n+m) O(n 2 ) if m=θ(n 2 ) DAGs Use topological sorting based algorithm O(n+m) Better than Dijkstra s algorithm, but still O(n 2 ) if m=θ(n 2 ) 16
17 Next Lecture Minimum spanning trees Definitions Kruskal s algorithm Prim s algorithm Course conclusion 17
Minimum Spanning Trees. Based on Mahesh Viswanathan s notes
Minimum Spanning Trees Based on Mahesh Viswanathan s notes MST: the problem Input: Connected graph with edge costs Goal: find such that is connected and the total cost of all edges in is the smallest T
More informationAlgorithms and Theory of Computation. Lecture 9: Dynamic Programming All Pair Shortest Paths
Algorithms and Theory of Computation Lecture 9: Dynamic Programming All Pair Shortest Paths Xiaohui Bei MAS 714 September 6, 2016 Nanyang Technological University MAS 714 September 6, 2016 1 / 20 Shortest
More informationLecture 9: Dijkstra s Shortest Path Algorithm
Lecture 9: Dijkstra s Shortest Path Algorithm CLRS 24.3 Outline of this Lecture Recalling the BFS solution of the shortest path problem for unweighted (di)graphs. The shortest path problem for weighted
More informationBreadth First Search, Dijkstra s Algorithm for Shortest Paths
CS 374: Algorithms & Models of Computation, Fall 2015 Breadth First Search, Dijkstra s Algorithm for Shortest Paths Lecture 1 October 20, 2015 Chandra & Manoj (UIUC) CS374 1 Fall 2015 1 / 42 Part I Breadth
More informationAnalysis of Algorithms I: Minimum Spanning Tree
Analysis of Algorithms I: Minimum Spanning Tree Xi Chen Columbia University We discuss the Minimum Spanning Tree problem. The input of the problem is an undirected and connected weighted graph G = (V,
More informationData Structures and Algorithms
Data Structures and Algorithms Session 20. April 8, 2009 Instructor: Bert Huang http://www.cs.columbia.edu/~bert/courses/3137 Announcements Homework 5 is out: You can use adjacency lists if you prefer
More informationCSE 100 Minimum Spanning Trees Unionfind
CSE 100 Minimum Spanning Trees Unionfind Announcements Midterm grades posted on gradesource Collect your paper at the end of class or during the times mentioned on Piazza. Regrades Submit your regrade
More informationOutline. Computer Science 331. Definitions: Paths and Their Costs. Computation of Minimum Cost Paths
Outline Computer Science 33 Computation of MinimumCost Paths Dijkstra s Mike Jacobson Department of Computer Science University of Calgary Lecture #33 Dijkstra s to Find MinCost Paths 3 Example 4 5 References
More informationAlgorithms and Data Structures Final Exam 100 Points
Algorithms and Data Structures Exam 100 Points Fill in the Blank (1 point each) 1. After many insertions and deletions in a hash table, it is possible that every unused node is marked as having been deleted.
More informationHomework #5. CMSC351  Spring 2013 PRINT Name :
Homework #5 CMSC351  Spring 2013 PRINT Name : Due: Thu May 9 th at the start of class o Grades depend on neatness and clarity. o Write your answers with enough detail about your approach and concepts
More informationChapter 23 Minimum Spanning Trees
Chapter 23 Kruskal Prim [Source: Cormen et al. textbook except where noted] This refers to a number of problems (many of practical importance) that can be reduced to the following abstraction: let G =
More informationBreadth First Search, Dijkstra s Algorithm for Shortest Paths
CS 473: Fundamental Algorithms, Spring 2011 Breadth First Search, Dijkstra s Algorithm for Shortest Paths Lecture 3 January 25, 2011 Sariel (UIUC) CS473 1 Spring 2011 1 / 49 Part I Breadth First Search
More information6.006 Introduction to Algorithms Lecture 15: Shortest Paths II
6.006 Introduction to Algorithms Lecture 15: Shortest Paths II Prof. Erik Demaine Today Bellman Ford algorithm for single source shortest paths Running time Correctness Handling negative weight cycles
More informationCSE 680: Introduction to Algorithms and Data Structures
Sample Final Exam CSE 680: Introduction to Algorithms and Data Structures 1. Solve the following recurrences by giving tight Θnotation bounds using the Master Method. If I thought you would need the actual
More informationMinimum Spanning Trees
Definitions Minimum Spanning Trees CSE 202 Day 16, Spring 2005 Neil Rhodes Given a connected undirected graph G=(V, E with positive weights on each edge (for simplicity, assume distinct weights! A spanning
More informationWeighted Graphs. Computing 2 COMP x1. Sedgewick Part 5: Chapter
Weighted Graphs Computing 2 COMP1927 17x1 Sedgewick Part 5: Chapter 20.120.4 21.121.3 WEIGHTED GRAPHS Some applications require us to consider a cost or weight costs/weights are assigned to edges Often
More informationGraph representation. Adjacency matrix Directed graph V = {1, 2, 3, 4} E = {(1, 2), (1, 3), (1, 4), (2, 3), (3, 4), (4, 2)}
Graph Algorithms Sets and sequences can only model limited relations between objects, e.g. ordering, overlapping, etc. Graphs can model more involved relationships, e.g. road and rail networks Graph: G
More informationExample Relational Networks
CMSC 206 Graphs Example Relational Networks School Friendship Network (from Moody 2001) Yeast Metabolic Network (from https://www.nd.edu/~networks/cell/) Terrorist Network (by Valdis Krebs, Orgnet.com)
More informationGraph Algorithms. Chapter 9
Chapter 9 Graph Algorithms The previous chapter introduced graphs and the basic traversal algorithms, depthfirst search and breadthfirst search. In this chapter, we will look at several useful graph
More informationPriority Queue  Heap
Priority Queue  Heap Priority Queue Typical Queue FirstIn, FirstOut. In certain situations NextIn, High PriorityOut. Examples: Print Queue smallest job exits the queue first. Operating System Process
More informationIntroduction to Algorithms
Introduction to Algorithms 6.046J/18.401J LECTURE 17 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadthfirst search Prof. Erik Demaine November 14, 005 Copyright
More informationLecture 15: The FloydWarshall Algorithm
Lecture 15: The FloydWarshall Algorithm CLRS section 252 Outline of this Lecture Recalling the allpairs shortest path problem Recalling the previous two solutions The FloydWarshall Algorithm 1 The AllPairs
More informationW4231: Analysis of Algorithms
W4231: Analysis of Algorithms Topological Sort Topological Sort Shortest Paths 10/26/1999 Given a directed graph G =(V,E), a topological sort of the vertices is an ordering v 1,...,v n of the vertices
More informationCSE 373 Analysis of Algorithms April 6, Solutions to HW 3
CSE 373 Analysis of Algorithms April 6, 2014 Solutions to HW 3 PROBLEM 1 [5 4] Let T be the BFStree of the graph G. For any e in G and e / T, we have to show that e is a cross edge. Suppose not, suppose
More information1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MST s 2/13/2017
CS 4 Section # Shortest Paths and MST s //07 Shortest Paths There are types of shortest paths problems: Single source single destination Single source to all destinations All pairs shortest path In today
More informationCSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.
Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure
More informationLecture 12: Greedy Algorithms and Minimum Spanning Tree
Lecture 12: Greedy Algorithms and Minimum Spanning Tree Introduction Optimal Substructure Greedy Choice Property Prim s algorithm Kruskal s algorithm Definitions Recall that a greedy algorithm repeatedly
More informationParallel Graph Algorithms (Chapter 10)
Parallel Graph Algorithms (Chapter 10) Vivek Sarkar Department of Computer Science Rice University vsarkar@cs.rice.edu COMP 422 Lecture 24 10 April 2008 Schedule for rest of semester 4/11/08  Deadline
More informationDesign and Analysis of Algorithms
CSE 1, Winter 201 Design and Analysis of Algorithms Lecture 7: BellmanFord, SPs in DAGs, PQs Class URL: http://vlsicad.ucsd.edu/courses/cse1w1/ Negative Edges Dijkstra s algorithm assumes that the shortest
More informationSPANNING TREES 11/3/16. Spanning trees. Dijkstra s algorithm using class SFdata. Backpointers. Backpointers
// Spanning trees What we do today: Talk about modifying an existing algorithm Calculating the shortest path in Dijkstra s algorithm Minimum spanning trees greedy algorithms (including Kruskal & Prim)
More informationCSC 323 Algorithm Design and Analysis Module 5: Graph Algorithms 5.1: DFS and BFS Traversal Algorithms
1) Consider the following graph: Solution: a) CSC 323 Algorithm Design and Analysis Module 5: Graph Algorithms 5.1: DFS and BFS Traversal Algorithms Instructor: Dr. Natarajan Meghanathan Sample Questions
More information1.1 What is a heap? 1.2 Representing a Heap. CS 124 Section #2 Heaps and Graphs 2/6/17
CS 124 Section #2 Heaps and Graphs 2/6/17 1 Heaps Heaps are data structures that make it easy to find the element with the most extreme value in a collection of elements. They are also known a priority
More informationPrelim 2. CS 2110, November 20, 2014, 5:30 PM Extra Total Question True/False Short Answer
Prelim 2 CS 2110, November 20, 2014, 5:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam is closed
More informationMinimum Spanning Trees
1 December 01 Minimum spanning trees (MST) One of the most famous greedy algorithms Given undirected graph G = (V, E), connected Weight function w : E R Spanning tree: tree that connects all nodes, hence
More informationData Structures and Algorithms Written Examination
Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where
More informationDATA STRUCTURES ALGORITHMS MOCK TEST DATA STRUCTURES ALGORITHMS MOCK TEST II
http://www.tutorialspoint.com DATA STRUCTURES ALGORITHMS MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Data Structures Algorithms. You can download
More informationExtended notes by Oscar Tengwall from lecture given by Gunnar Kreitz.
Part I Lecture 5: Graphs 20051008 Extended notes by Oscar Tengwall from lecture given by Gunnar Kreitz. 1 Graph Data Structures Graphs in mathematics are usually represented by two sets V and E (vertices
More informationQuick and dirty approach to solving optimization problems Not necessarily ends up with an optimal solution
Greedy Algorithms Greedy Technique What is it? How does it work? Quick and dirty approach to solving optimization problems Not necessarily ends up with an optimal solution Problems explored Coin changing
More informationBreadthFirst Search of Graphs
BreadthFirst Search of Graphs Analysis of Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Applications of BreadthFirst Search of Graphs a) Single Source
More informationChapter 23: Minimum Spanning Trees
Graph Algorithms  Spring 2011 Set 9. Lecturer: Huilan Chang Reference: (1) Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 2nd Edition, The MIT Press. (2) Lecture notes from C. Y. Chen
More informationCSE 548: Analysis of Algorithms. Lecture 10 ( Dijkstra s SSSP & Fibonacci Heaps )
CSE 548: Analysis of Algorithms Lecture 10 ( Dijkstra s SSSP & Fibonacci Heaps ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Fall 2016 Fibonacci Heaps ( Fredman& Tarjan, 1984 )
More informationBinary Heaps. CSE 373 Data Structures
Binary Heaps CSE Data Structures Readings Chapter Section. Binary Heaps BST implementation of a Priority Queue Worst case (degenerate tree) FindMin, DeleteMin and Insert (k) are all O(n) Best case (completely
More informationCS61B, Spring 2003 Discussion #13 Amir Kamil UC Berkeley 4/14/03
CS61B, Spring 2003 Discussion #13 Amir Kamil UC Berkeley 4/14/03 Topics: Graph Algorithms 1 Graph Algorithms There are many algorithms that can be applied to graphs. Many of these are actually used in
More informationToday s Outline. CS 362, Lecture 17. Prim s Algorithm. Example Run. Runtime? Prim s Algorithm. Jared Saia University of New Mexico
Today s Outline Runtime? Prim s Algorithm CS 362, Lecture 17 Jared Saia University of New Mexico The runtime fo the Kruskal s alg. will depend on the implementation of the disjointset data structure.
More informationEE2008 Data Structure & Algorithm  Tutorial
EE2008 Data Structure & Algorithm  Tutorial Tutor : Prof. Maode Ma Email: emdma@ntu.edu.sg Office: Rm. S2.2B227 Tel No. 67904385 Website: http://www.ntu.edu.sg/home/emdma Topic 1: Mathematics 1. Concepts
More informationUMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels. Fall, Final Review
UMass Lowell Computer Science 91.404 Analysis of Algorithms Prof. Karen Daniels Fall, 2009 Final Review Review of Key Course Material What s It All About? Algorithm: steps for the computer to follow to
More information4.5 Minimum Spanning Tree
4. Minimum Spanning Tree Minimum Spanning Tree Minimum spanning tree. Given a connected graph G = (V, E) with realvalued edge weights c e, an MST is a subset of the edges T E such that T is a spanning
More informationQuiz 2 Solutions. adj(s) = [a, c, d], adj(a) = [ ], adj(c) = [e, b], adj(b) = [d], adj(d) = [c], adj(e) = [s]. (a) Breadth First Search.
Introduction to Algorithms November 12, 2008 Massachusetts Institute of Technology 6.006 Fall 2008 Professors Ronald L. Rivest and Sivan Toledo Quiz 2 Solutions Problem 1. BFS/DFS [10 points] (2 parts)
More informationEndTerm Examination Second Semester [MCA] MAYJUNE 2006
Second Semester [MCA] MAYJUNE 2006 Subject: Data Structure Time: 3 Hours Maximum Marks: 60 Note: Question 1. is compulsory and is of 20 marks. Attempt one out of two questions from remaining four units.
More information4. GREEDY ALGORITHMS II
4. GREEDY ALGORITHMS II Dijkstra's algorithm minimum spanning trees Prim, Kruskal, Boruvka singlelink clustering mincost arborescences Lecture slides by Kevin Wayne Copyright 2005 PearsonAddison Wesley
More informationCSC 344 Algorithms and Complexity. Optimization Problems
CSC 344 Algorithms and Complexity Lecture #6 Greedy Algorithms Optimization Problems An optimization problem is the problem of finding the best solution from all feasible solutions Shortest path is an
More informationLecture 8: Priority Queue
Lecture 8: Priority Queue CSC2100 Data Structure Yufei Tao CSE department, CUHK March 12, 2011 In this lecture, we will learn a structure called the priority queue, which is also known as the heap. It
More informationWeek 5. Breadthfirst and Depthfirst search
Week 5 and 1 2 3 4 5 6 General remarks We consider the simplest graph algorithm, breadthfirst (). We apply to compute shortest paths. Then we consider the second main graph algorithm, depthfirst ().
More informationThe A* Search Algorithm. Siyang Chen
The A* Search Algorithm Siyang Chen Introduction A* (pronounced Astar ) is a search algorithm that finds the shortest path between some nodes S and T in a graph. Heuristic Functions Suppose we want to
More information(1.2) Which of the following data structures is more appropriate as an implementation of the queue ADT: singly linked list or doubly linked list?
QUESTION 1 (25 marks) Short answer questions you do not need to provide any justifications for your answers. Just fill in your answer in the space provided. For each correct answer, 1 mark will be awarded.
More informationMinimum Spanning Tree
Minimum Spanning Tree Minimum spanning tree. Given a connected graph G = (V, E) with real valued edge weights c e, an MST is a subset of the edges T E such that T is a spanning tree whose sum of edge
More informationShortest Paths. Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij
Shortest Paths Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij 1 Contents The shortest path problem: Statement Versions Applications Algorithms Reminders: Dijkstra, BellmanFord,
More informationMinimum Spanning Trees
Minimum Spanning Trees CONTENTS Introduction to Minimum Spanning Trees Applications of Minimum Spanning Trees Optimality Conditions Kruskal's Algorithm Prim's Algorithm Sollin's Algorithm Reference: Sections.
More informationTrue False (1 points each) (Circle the correct answer)
CS 2420 Exam 2 Fill in the blank (1 point each blank): 1. probing is simple to implement, but typically results in primary, which causes performance to degrade rapidly. 2. probing still causes secondary
More informationCSE373: Data Structures & Algorithms Lecture 6: Priority Queues. Kevin Quinn Fall 2015
CSE373: Data Structures & Algorithms Lecture 6: Priority Queues Kevin Quinn Fall 2015 A Quick Note: Homework 2 due tonight at 11pm! 2 A new ADT: Priority Queue Textbook Chapter 6 Nice to see a new and
More informationOptimal trees and forests. Filip Malmberg
Optimal trees and forests Filip Malmberg Todays lecture Trees and forests Optimal forests Minimum spanning forests Shortest path forests Applications in image segmentation Part 1: Forests and trees Forests
More informationChapter. Weighted Graphs. Contents
Chapter 7 Weighted Graphs Contents 7.1 SingleSource Shortest Paths.............. 341 7.1.1 Dijkstra s Algorithm.................. 342 7.1.2 The BellmanFord Shortest Paths Algorithm..... 349 7.1.3 Shortest
More informationSpanning Trees. What is Tree? Minimum Spanning Tree, Kruskal s and Prim s Algorithms, Applications in Networking. Spanning Tree properties: Trees. No.
Minimum Spanning Tree, s and Prim s s, Applications in Networking Submitted by: Hardik Parikh Soujanya Soni OverView Tree definition Spanning Trees Minimum Spanning Trees s and s for Minimum Spanning Trees
More informationUCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis
UCSD CSE 1, Spring 01 [Section B00] Mathematics for Algorithm and System Analysis Lecture 17 Class URL: http://vlsicad.ucsd.edu/courses/cse1s1/ Lecture 17 Notes Last time Recurrences revisited Types of
More informationElementary Graph Algorithms
Topics Elementary Graph Algorithms Representation of Graphs Breadthfirst Search Depthfirst Search Topological Sort Source: Introduction to Algorithms, Second Edition by Cormen, Leiserson, Rivest & Stein
More informationExam study sheet for CS2711. List of topics
Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure
More informationUniversity of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2008
University of New Mexico Department of Computer Science Final Examination CS 362 Data Structures and Algorithms Spring, 2008 Name: Email: Print your name and email, neatly in the space provided above;
More informationOutline BFS PFS Traversal Cycle DAG Connectivity. Graphs and Digraphs. BFS Priority search DAG Connectivity. Lecturer: Georgy Gimel farb
Graphs and Digraphs BFS Priority search DAG Connectivity Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 67 1 Breadthfirst Search 2 Priorityfirst Search of Digraphs 3 Algorithms
More informationFall 2014 David Wagner MT1 Soln
CS 70 Algorithms Fall 204 David Wagner MT Soln I include explanations for many of the answers, to help you understand why they are correct. You did not need to include any of these explanations in your
More information4.5 Minimum Spanning Tree
4.5 Minimum Spanning Tree Minimum Spanning Tree Problem (and applications) Cutproperty and Cycleproperty (inc. proof) MST algorithms: Prim Kruskal and UnionFind ReverseDelete 4.5 Minimum Spanning Tree
More informationCourse Notes for CS336: Graph Theory
Course Notes for CS336: Graph Theory Jayadev Misra The University of Texas at Austin 5/11/01 Contents 1 Introduction 1 1.1 Basics................................. 2 1.2 Elementary theorems.........................
More informationChapter 20. Priority Queues
Chapter 20 Priority Queues We have already discussed and used priority queues in a few places in this class. We used them as an example of an abstract data type. We also used them in the priorityfirst
More informationDesign and Analysis of Algorithms April 20, 2015 Massachusetts Institute of Technology Profs. Erik Demaine, Srini Devadas, and Nancy Lynch
Design and Analysis of Algorithms April 20, 2015 Massachusetts Institute of Technology 6.046J/18.410J Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Quiz 2 Solutions Quiz 2 Solutions Do not open this
More informationGreedy Algorithms CSE 6331
Greedy Algorithms CSE 6331 Reading: Sections 16.1, 16.2, 16.3, Chapter 23. 1 Introduction Optimization Problem: Construct a sequence or a set of elements {x 1,..., x k } that satisfies given constraints
More informationAS2342 M.C.A.1 st Semester, Examination2013 Paper fourth SubjectData structure with algorithm
AS2342 M.C.A.1 st Semester, Examination2013 Paper fourth SubjectData structure with algorithm Time: Three Hours] [Maximum Marks: 60 Note: attempt all questions. Q. no. 1 is compulsory. Answer any four
More information8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm
8 Priority Queues 8 Priority Queues A Priority Queue S is a dynamic set data structure that supports the following operations: S. build(x 1,..., x n ): Creates a datastructure that contains just the elements
More informationPrelim 2 Solutions. CS 2110, November 20, 2014, 5:30 PM Extra Total Question True/False Short Answer
Prelim 2 Solutions CS 2110, November 20, 2014, 5:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam
More informationLecture 16: Minimum Spanning Trees. (Reading:AM&O Chapter 13)
Lecture 16: Minimum Spanning Trees (Reading:AM&O Chapter 13) The Mininum Spanning Tree Problem Given: Undirected connected network G = (N, A) with positive weights c ij associated with each arc (i, j)
More informationEECS 311 Data Structures Final Exam Don t Panic!
June, 007 EECS Data Structures Final Exam Don t Panic!. [0 pts] In the boxes below, show the result of adding the given numbers to a heap, using < as the predicate. Circle items that had to move at each
More informationLab Manual. Algorithms Design (Pr) COT311
Lab Manual Algorithms Design (Pr) COT311 Lab Instructions Several practicals / programs? Whether an experiment contains one or several practicals /programs One practical / program Lab Teacher forms groups
More informationLine Segment Intersection
Line Segment Intersection The intersection problem: 1 Given 2 object (in 2/3D), find out whether they intersect, and if so, what is the point of intersection. The objects may be complex, like circles.
More informationGraph Algorithms. Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar
Graph Algorithms Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar To accompany the text Introduction to Parallel Computing, Addison Wesley, 3. Topic Overview Definitions and Representation Minimum
More informationParallel and Sequential Data Structures and Algorithms Lecture (Spring 2012) Lecture 20 Leftist Heaps and Sorting Lower Bounds
Lecture 20 Leftist Heaps and Sorting Lower Bounds Parallel and Sequential Data Structures and Algorithms, 15210 (Spring 2012) Lectured by Margaret ReidMiller 29 March 2012 Today:  Priority Queues and
More informationComputer Science E119: Data Structures Fall 2012
Computer Science E9: Data Structures Fall 0 Problem Set Due prior to lecture on Wednesday, December No submissions will be accepted after Sunday, December, at :9 p.m. so that we can post solutions before
More informationCMSC 451: Graph Properties, DFS, BFS, etc.
CMSC 451: Graph Properties, DFS, BFS, etc. Slides By: Carl Kingsford Department of Computer Science University of Maryland, College Park Based on Chapter 3 of Algorithm Design by Kleinberg & Tardos. Graphs
More informationDynamic programming CS325
Dynamic programming CS325 Shortest path in DAG DAG: directed acyclic graph A DAG can be linearized: all the nodes arranged in a line and the edges only goes from left to right (Chapter 3.3.2) Consider
More informationGraph. Consider a graph, G in Fig Then the vertex V and edge E can be represented as:
Graph A graph G consist of 1. Set of vertices V (called nodes), (V = {v1, v2, v3, v4...}) and 2. Set of edges E (i.e., E {e1, e2, e3...cm} A graph can be represents as G = (V, E), where V is a finite and
More informationHeaps. Heapsort. (CLRS 6)
Heaps. Heapsort. (CLRS 6) So far we have discussed tools necessary for analysis of algorithms (growth, summations and recurrences) and we have seen a couple of sorting algorithms as casestudies. Today
More informationCSci 231 Homework 9. Graph Algorithms. CLRS Chapter 22, 24
CSci 231 Homework 9 Graph Algorithms CLRS Chapter 22, 2 1. [CLRS 22.15] Give and analyse an algorithm for computing the square of a directed graph G given in (a) adjacencylist representation and (b)
More informationCS 146 Final Exam 1 Grade:
CS 146 Final Exam 1 Name: Grade: The test will be open book, open notes, 2 hours and 15 minutes time limit. Calculators allowed for numerical, nonprogrammed calculations, but not computers. Please write
More informationrst searchonly makes sense in the context of exploring the part of the graph that is reachable
BreadthFirst Search Breadthrst search is the variant of search that is guided by a queue, instead of depthrst search's stack (remember, depthrst search does use a stack, the one implicit in its recursion).
More informationU.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 2 Professor: Satish Rao November 21, Midterm 2 Solutions
U.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 2 Professor: Satish Rao November 21, 2013 Midterm 2 Solutions 1 True Xor False [2 points each] Write either True or False to the left of the number.
More informationPriority Queues Heaps Heapsort
Priority Queues Heaps Heapsort Complete the EditorTrees partner(s) evaluation by today (Thursday) 5 PM. Use your individual log to give them useful feedback! Basic operations Implementation options Each
More informationPriority Queues. Binary heaper Leftist heaper Binomial heaps Fibonacci heaps. Priority queues are important in, among other things, operating systems
Priority Queues Binary heaper Leftist heaper Binomial heaps Fibonacci heaps Priority queues are important in, among other things, operating systems (process control i multitasking systems), search algorithms
More informationBasic Traversal and Search Techniques
Basic Traversal and Search Techniques Traversal vs Search Definition 1 Traversal of a binary tree involves examining every node in the tree. Definition 2 Search involves visiting nodes in a graph in a
More informationIntroduction to kdtrees
Introduction to kdtrees Page 1 of 100 Dimension of data is k (but common to say kd tree of dimension 3 instead of 3dtree). kdtrees are binary trees Designed to handle spatial data in a simple way For
More informationSpanning Trees 4/8/15. Undirected trees
/8/ Undirected trees An undirected graph is a tree if there is exactly one simple path between any pair of Lecture CS Spring Spanning Trees Root of tree? It doesn t matter choose any vertex for the root
More informationKINGS COLLEGE OF ENGINEERING
KINGS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING UNIT I ALGORITHM ANALYSIS 1. What is an Algorithm? May/June 2006, Nov/Dec 2008 2. State the Euclid s algorithm for finding GCD
More informationCS 561, Lecture 4. Jared Saia University of New Mexico
CS 561, Lecture 4 Jared Saia University of New Mexico Outline Loop Invariants Heaps 1 Correctness of Algorithms The most important aspect of algorithms is their correctness An algorithm by definition always
More information