Homework 4 Solutions CSE 101 Summer 2017
|
|
- Giles Lamb
- 6 years ago
- Views:
Transcription
1 Homework 4 Solutions CSE 101 Summer Scheduling 1. LPT Scheduling (a) Find the Upper Bound for makespan of LPT Scheduling for P C max. (b) Find a tight worst-case example for the makespan achieved by LPT Scheduling in comparison to the optimum makespan for m = 5 processors. (c) Prove that if optimal makespan of LPT schedule, C max < 3.p k, then each processor has at most two jobs. (d) Prove that if each processor has at most two jobs, then LPT is always optimal. (a) Refer to Lemma 7 in Extra Reading (b) To achieve a tight worst-case for the makespan by LPT Scheduling with 5 processors, we choose n = 2(5) + 1 = 11 jobs as follows: 2 jobs of size 2(5) 1 = 9, 2 jobs of size 2(5) 2 = 8, 2 jobs of size 2(5) 3 = 7, 2 jobs of size 2(5) 4 = 6(= 5 + 1), 3 jobs of size 5. The Gantt-Chart for this list {9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5} using LPT Scheduling in comparison to the optimum makespan is: 1
2 ( m )C max = ( 19 T 15 )15 = 19 = CLP max. (c) Refer to Corollary 3 in Extra Reading (d) Refer to Corollary 4 in Extra Reading 2. Single Processor Scheduling (a) The following n = 8 jobs with given processing times have to be scheduled on a single processor with the objective of minimizing the maximum lateness L max. d j is the maximum delay of each process. A B C D E F G H p j d j Calculate the values of L max and U j (i) If you schedule the jobs in the given order - A,B,..,H (ii) If you schedule the jobs using EDD algorithm (iii) If you schedule the jobs using the Moore s algorithm (b) Prove that there is no better solution than the one obtained using Earliest Due Date (EDD) algorithm, to the problem of minimizing maximum lateness. (c) Prove that Moore s algorithm provides the optimal solution for 1 U j. (a) (i) A B C D E F G H p j d j C j L j Just scheduled in that order would give: L max = 43 (job H) Uj = 6 (jobs C, D, E, F, G, H) 2
3 (ii) D F E A G C H B p j d j C j L j Scheduling using EDD algorithm would give: L max = 40 (job B) Uj = 7 (jobs A, B, C, E, F, G, H) (iii) The jobs are initially scheduled in EDD order. Scheduling using Moore s algorithm would give: L max = 40 (job B) Uj = 5 (jobs A, C, F, G, H) (b) Proof (by contradiction). Assume that, for a given set of jobs, schedule S is optimal even though the jobs are not scheduled according to EDD. Then there must be at least two jobs, say j1 and j2 having delays d j1 > d j2, and j1 being scheduled before j2, as shown: 3
4 On swapping jobs j1 and j2, we get In this schedule S, L j2 = C j2 d j2 < C j2 d j2 (since C j2 > C j1) L j1 = C j1 d j1 = C j2 d j1 < C j2 d j2 (since d j1 > d j2 ) Then, for every other job j, (j j1,j2) This means, L j = C j d j < C j d j (since they are not rescheduled in S ) max{l j1, L j2, max{l j}} max{l j1, L j2, max{l j }} = L max S L max S But this is a contradiction to the assumption that S is optimal. It follows that EDD is optimal for 1 L max (c) Proof (by induction). Step 1: If there exists a schedule such that there are no late jobs, then there won t be any late job in the schedule obtained by following the EDD algorithm. [Refer 2(b] Step 2: Assume that there exists a schedule S with U j = k. We need to prove that there can t be another schedule S such that U j = k + 1. This is easy to see since the total processing time of on-time jobs is as small as possible, given that the job with the largest processing time is removed always. 2 Graphs 3. You are given an undirected unweighted graph G = (V, E), V = n, E = m. Determine, whether this graph contains a circuit or not. (a) We will use a DFS algorithm to solve this problem. Let s color each node to two colors: red and blue. If the node hasn t been visited yet by DFS, then the color of the node is red. Otherwise, the color of the node is blue. If at some step DFS tries to visit the node with the blue color, then there exists a circuit. 4
5 (b) If the DFS algorithm is trying to enter a node v with the blue color from node u, this means that we have visited v before. If we take the path from v to u (which was constructed by a DFS tree) and add to this path edge (u, v), which exists as we are trying to visit node v from u, then we will get a circuit. If there exists a circuit in the graph, then, at some point, DFS will visit one of its nodes. Let that node be v. As node v is part of a circuit, it has at least two edges (v, a) and (v, b), such that there is a path from a to b that doesn t go through v. This path will be processed sooner or later by DFS and we will get to node b from a. Then, we will try to visit v, which is going to have the blue color. (c) The complexity of the solution equals the complexity of DFS, i.e. O(n + m) 4. There are n cities on a plane with coordinates (x 1, y 1 ), (x 2, y 2 ),..., (x n, y n ). All cities are distinct and located at different points on the plane. The city 1 has access to electricity. You need to connect cities with wires, such that all cities will have access to electricity. A city has access to electricity if it is city 1 or if it is connected with a wire to another city, that has access to electricity. The length of the wire that connects the two cities equals the euclidean distance between these cities. Your task is to connect the cities with wires, such that the total length of all wires is minimized. (a) Let matrix d[i][j] be equal to the euclidean distance between cities i and j, i.e. d[i][j] = (xi x j ) 2 + (y i y j ) 2. As a result, we have a full graph G = (V, E) with nodes as cities and the weight on edges as euclidean distances between the cities. In order to find the answer, we will find the minimum spanning tree of this graph. This tree will be the answer to our problem. (b) Let G = (V, E ) be a graph that connects all nodes in G and the sum of weights in this graph is as small as possible. Let s find the minimum spanning tree of G. The sum of weights in the minimum spanning tree of G will be less than or equal to the sum of weights of graph G, thus it will be optimal. But as G is a subgraph of G, then the total sum of weights of the spanning tree of G is less than or equal to the sum of all weights in the spanning tree of G. Thus, it is also optimal. (c) The time complexity of this solution equals the time complexity of finding the minimum spanning tree in a full graph. If we apply Prim s algorithm to this purpose, then the time complexity is O(n 2 ). 5. You have a chess board n m. There is a knight on cell (x s, y s ). The knight can make moves from cell (x, y) to cells (x + 1, y + 2), (x 1, y + 2), (x + 1, y 2), (x 1, y 2), (x + 2, y 1), (x 2, y 1), (x + 2, y + 1) and (x 2, y + 1) (all cells must be on the board). Find the minimum number of steps the knight needs to make to get from cell (x s, y s ) to cell (x f, y f ). (a) If we assume that each cell of the board is a node, then we can connect a node that corresponds to cell (x, y) with nodes that correspond to cells (x + 1, y + 2), (x 1, y + 2), (x + 1, y 2), (x 1, y 2), (x + 2, y 1), (x 2, y 1), (x + 2, y + 1) and (x 2, y + 1) (all cells must be on the board) with undirected edges. As a result, we will have an undirected unweighted graph. We then launch BFS from the node which corresponds to cell (x s, y s ) and find the distance to the node which corresponds to cell (x f, y f ). 5
6 (b) Let s assume that we have an optimal sequence of steps from cell (x s, y s ) to (x f, y f ). As we can see, this sequence will correspond to some path in the constructed graph from the node that corresponds to cell (x s, y s ) to the node that corresponds to cell (x f, y f ). But as BFS always finds the minimum distance from the node from which it starts to all other nodes, then the path found in BFS will also be optimal. (c) The time complexity equals the time complexity of BFS. There are nm nodes in the constructed graph and less than 4nm edges. The overall time complexity is O(nm). 6. You are given an undirected connected weighted graph G = (V, E), V = n, E = m. The weights of all edges are positive integer numbers. Your task is to delete edges in this graph so that the resulting graph will be connected and the product of all weights of all edges in this graph will be as small as possible. (a) Let s construct another graph G = (V, E ), such that V = V, E = E and w(e ) = log(w(e)) for all e E and e E. Then, we will find the minimum spanning tree in G with Prim s algorithm. We will take the same tree G (the same nodes and edges). This tree in G will be the graph that we are looking for. (b) When we are looking for the minimum spanning tree in G, we are minimizing the following function log(w(e 1)) + log(w(e 2)) log(w(e k )) = log(w(e 1)w(e 2)...w(e k )), where k is the number of edges in the resulting graph. But minimizing log(x) for x > 0 means minimizing x. Thus, we are minimizing function w(e 1)w(e 2)...w(e k ), when we search for the minimum spanning tree. (c) The time complexity equals the number of operations required to get a new graph plus the time complexity of Prim s algorithm, i.e. O(n + m) + O(n 2 ) = O(n 2 ). 7. There is a set of n courses. Each course has its prerequisites (from the same set). So course i is assigned a set of courses that are required to be completed before course i starts. You are given a set of n courses, and each course is provided with a list of prerequisites. Find a schedule (a list) of courses, if such exists, such that all n courses are in this list and they all can be completed. If there is no such a schedule, just output 1. For example, let s say we have 5 courses and a list (A, D, C, B, E). We go from left to right and try to complete a current course. If all prerequisites for the current course are completed, then the current course can also be completed. (a) Let s construct a graph G = (V, E), V = n, E = m, such that each node represents some course. There is a directed edge from node u to node v if the course for node u is a prerequisite for the course for node v. Now, we have a directed graph. Let s find topological sorting of this graph. If there is such, then the list will be courses given in a topological sorted order of their corresponding nodes. 6
7 (b) Let s say v 1, v 2,..., v n is a topological order of nodes in graph G. Then, from the properties of the topological sort we know, that there is no edge from v i to v k, when i > k, i.e. all corresponding courses can be completed. This list also includes all nodes, which makes it a valid schedule. Now, let s say u 1, u 2,..., u n is a list of nodes, which correspond to courses from the answer to this problem. Then, this list will also be the one of the topological orders of graph G. Indeed, as this is a valid schedule, all courses can be completed, i.e. there can only be edges (v i, v k ), such that i < k. (c) The time complexity is to construct a graph and to find its topological order, i.e. O(n + m). 8. You are given a rooted tree G = (V, E), V = n, E = m. You have q online queries (u, v). For each query (u, v) you need to answer whether u is an ancestor of v in the tree G. (a) Let s use DFS to solve this problem. We launch DFS from the root. We will need two additional values for each node v: in[v] and out[v]. in[v] is a time when DFS visits node v. out[v] is a time when DFS leaves node v. The time starts with zero and increases by one each time we enter or quit some node in DFS. Then, if in[a] < in[b] and out[b] < out[a], a is an ancestor of b. (b) If in[a] < in[b], this means that we have visited a sometime before we have visited b. If out[b] < out[a], this means that by the time we have left b, we are still in the subtree, in which a is a root. Now, if a is an ancestor of b, then we will visit a first, then we will visit b, then we will quit b and, finally, we will quit a. This leads to our inequality. (c) We need O(n + m) for DFS and O(q) for all queries. Each query takes O(1) time to answer. The overall complexity will be O(n + m + q). 9. You are given a weighted directed graph G = (V, E), V = n, E = m with positive weights. You are also given a node s in this graph. Find such node v, such that there is a path from v to s and that among all possible such nodes, the shortest path from v to s is as large as possible. (a) Let s construct graph G = (V, E ) such that G is a copy of G, but all edges are directed in an opposite direction. Let s find shortest paths from node s to all other nodes in G. We can do this with Dijkstra s algorithm. Then, among all these paths, we choose the one with the maximum value. The node, to which this path leads is the answer to our problem. (b) Any path from s to v in G is a path from v to s in G and vice versa. This means that the shortest path from v to s in G is the shortest path from s to v in G. This proves the correctness of our solution. (c) The time complexity equals the time complexity of building graph G and using Dijkstra s algorithm on it, i.e. O(n + m) + O(n 2 ) = O(n 2 ) 7
8 3 Linear Programming 10. A company manufactures two products A and B. The company earns $3 for each piece of A and $2 for each piece of B. Raw materials V1 and V2 are necessary to build these products. But there are only 8 parts of V1 and 6 parts of V2 available. To manufacture single piece of product A, 2 parts of V1 and 1 part of V2 is required. To manufacture single piece of product B, 1 part of V1 and 1 part of V2 is required. How many pieces of A and B does the company have to manufacture when the objective function is to maximize the earning? (a) Formulate the mathematical program. (b) Solve the problem graphically. (c) Solve the problem with the Simplex algorithm. (d) Give an interpretation of the dual values: If the company could have access to one more piece of V1, how would the production program and the earning change? If the company could have access to one more piece of V2, how would the production program and the earning change? see lecture slides 8
Theorem 2.9: nearest addition algorithm
There are severe limits on our ability to compute near-optimal tours It is NP-complete to decide whether a given undirected =(,)has a Hamiltonian cycle An approximation algorithm for the TSP can be used
More informationCSE 331: Introduction to Algorithm Analysis and Design Graphs
CSE 331: Introduction to Algorithm Analysis and Design Graphs 1 Graph Definitions Graph: A graph consists of a set of verticies V and a set of edges E such that: G = (V, E) V = {v 0, v 1,..., v n 1 } E
More informationLecture 3: Graphs and flows
Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected
More informationGraph Algorithms. Chapter 22. CPTR 430 Algorithms Graph Algorithms 1
Graph Algorithms Chapter 22 CPTR 430 Algorithms Graph Algorithms Why Study Graph Algorithms? Mathematical graphs seem to be relatively specialized and abstract Why spend so much time and effort on algorithms
More informationCS521 \ Notes for the Final Exam
CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )
More informationApproximation Algorithms
Approximation Algorithms Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Basics A 4 credit unit course Part of Theoretical Computer Science courses at the Laboratory of Mathematics There will be 4 hours
More informationLecture 8: The Traveling Salesman Problem
Lecture 8: The Traveling Salesman Problem Let G = (V, E) be an undirected graph. A Hamiltonian cycle of G is a cycle that visits every vertex v V exactly once. Instead of Hamiltonian cycle, we sometimes
More informationCOMP 182: Algorithmic Thinking Prim and Dijkstra: Efficiency and Correctness
Prim and Dijkstra: Efficiency and Correctness Luay Nakhleh 1 Prim s Algorithm In class we saw Prim s algorithm for computing a minimum spanning tree (MST) of a weighted, undirected graph g. The pseudo-code
More informationCSE 417: Algorithms and Computational Complexity. 3.1 Basic Definitions and Applications. Goals. Chapter 3. Winter 2012 Graphs and Graph Algorithms
Chapter 3 CSE 417: Algorithms and Computational Complexity Graphs Reading: 3.1-3.6 Winter 2012 Graphs and Graph Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
More informationCSci 231 Final Review
CSci 231 Final Review Here is a list of topics for the final. Generally you are responsible for anything discussed in class (except topics that appear italicized), and anything appearing on the homeworks.
More informationMathematical and Algorithmic Foundations Linear Programming and Matchings
Adavnced Algorithms Lectures Mathematical and Algorithmic Foundations Linear Programming and Matchings Paul G. Spirakis Department of Computer Science University of Patras and Liverpool Paul G. Spirakis
More informationThese are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions.
CSE 591 HW Sketch Sample Solutions These are not polished as solutions, but ought to give a correct idea of solutions that work. Note that most problems have multiple good solutions. Problem 1 (a) Any
More informationAnnouncements. CSEP 521 Applied Algorithms. Announcements. Polynomial time efficiency. Definitions of efficiency 1/14/2013
Announcements CSEP 51 Applied Algorithms Richard Anderson Winter 013 Lecture Reading Chapter.1,. Chapter 3 Chapter Homework Guidelines Prove that your algorithm works A proof is a convincing argument Give
More informationCombinatorial Optimization
Combinatorial Optimization Frank de Zeeuw EPFL 2012 Today Introduction Graph problems - What combinatorial things will we be optimizing? Algorithms - What kind of solution are we looking for? Linear Programming
More informationGraphs. Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1
Graphs Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1 Warmup Discuss with your neighbors: Come up with as many kinds of relational data as you can (data that can be represented with a graph).
More informationApproximation Algorithms
Approximation Algorithms Given an NP-hard problem, what should be done? Theory says you're unlikely to find a poly-time algorithm. Must sacrifice one of three desired features. Solve problem to optimality.
More informationModule 6 P, NP, NP-Complete Problems and Approximation Algorithms
Module 6 P, NP, NP-Complete Problems and Approximation Algorithms Dr. Natarajan Meghanathan Associate Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu
More informationPractical Session No. 12 Graphs, BFS, DFS, Topological sort
Practical Session No. 12 Graphs, BFS, DFS, Topological sort Graphs and BFS Graph G = (V, E) Graph Representations (V G ) v1 v n V(G) = V - Set of all vertices in G E(G) = E - Set of all edges (u,v) in
More informationChapter 9 Graph Algorithms
Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a
More informationChapter 9 Graph Algorithms
Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 29 Approximation Algorithms Load Balancing Weighted Vertex Cover Reminder: Fill out SRTEs online Don t forget to click submit Sofya Raskhodnikova 12/7/2016 Approximation
More informationMatching Theory. Figure 1: Is this graph bipartite?
Matching Theory 1 Introduction A matching M of a graph is a subset of E such that no two edges in M share a vertex; edges which have this property are called independent edges. A matching M is said to
More informationModule 6 NP-Complete Problems and Heuristics
Module 6 NP-Complete Problems and Heuristics Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu P, NP-Problems Class
More informationCS490 Quiz 1. This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed.
CS490 Quiz 1 NAME: STUDENT NO: SIGNATURE: This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed. Not all questions are of the same
More informationAdvanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret
Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret Greedy Algorithms (continued) The best known application where the greedy algorithm is optimal is surely
More informationComputer Science 280 Fall 2002 Homework 10 Solutions
Computer Science 280 Fall 2002 Homework 10 Solutions Part A 1. How many nonisomorphic subgraphs does W 4 have? W 4 is the wheel graph obtained by adding a central vertex and 4 additional "spoke" edges
More informationGreedy Algorithms. Previous Examples: Huffman coding, Minimum Spanning Tree Algorithms
Greedy Algorithms A greedy algorithm is one where you take the step that seems the best at the time while executing the algorithm. Previous Examples: Huffman coding, Minimum Spanning Tree Algorithms Coin
More informationCSE 431/531: Analysis of Algorithms. Greedy Algorithms. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo
CSE 431/531: Analysis of Algorithms Greedy Algorithms Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Main Goal of Algorithm Design Design fast algorithms to solve
More informationApproximation Algorithms
Approximation Algorithms Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Basics A new 4 credit unit course Part of Theoretical Computer Science courses at the Department of Mathematics There will be 4 hours
More informationGraph Algorithms Using Depth First Search
Graph Algorithms Using Depth First Search Analysis of Algorithms Week 8, Lecture 1 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Graph Algorithms Using Depth
More informationAlgorithm Computation of a Single Source Shortest Path in a Directed Graph. (SSSP algorithm)
.. PATH PROBLEMS IN DIRECTED GRAPHS 141 This algorithm is based on the Dynamic Programming idea. It is due to E. W. Dijkstra and it takes O(n ) time for graphs of n nodes, in the case in which labels form
More informationTaking Stock. IE170: Algorithms in Systems Engineering: Lecture 17. Depth-First Search. DFS (Initialize and Go) Last Time Depth-First Search
Taking Stock IE170: Algorithms in Systems Engineering: Lecture 17 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University March 2, 2007 Last Time Depth-First Search This Time:
More informationCS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018
CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved.
More informationDesign and Analysis of Algorithms
CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 9: Minimum Spanning Trees Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Goal: MST cut and cycle properties Prim, Kruskal greedy algorithms
More informationGraph Algorithms. Andreas Klappenecker. [based on slides by Prof. Welch]
Graph Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Directed Graphs Let V be a finite set and E a binary relation on V, that is, E VxV. Then the pair G=(V,E) is called a directed graph.
More informationTrees, Trees and More Trees
Trees, Trees and More Trees August 9, 01 Andrew B. Kahng abk@cs.ucsd.edu http://vlsicad.ucsd.edu/~abk/ How You ll See Trees in CS Trees as mathematical objects Trees as data structures Trees as tools for
More information11. APPROXIMATION ALGORITHMS
Coping with NP-completeness 11. APPROXIMATION ALGORITHMS load balancing center selection pricing method: weighted vertex cover LP rounding: weighted vertex cover generalized load balancing knapsack problem
More information11. APPROXIMATION ALGORITHMS
11. APPROXIMATION ALGORITHMS load balancing center selection pricing method: vertex cover LP rounding: vertex cover generalized load balancing knapsack problem Lecture slides by Kevin Wayne Copyright 2005
More informationLecture Summary CSC 263H. August 5, 2016
Lecture Summary CSC 263H August 5, 2016 This document is a very brief overview of what we did in each lecture, it is by no means a replacement for attending lecture or doing the readings. 1. Week 1 2.
More informationTheory of Computing. Lecture 4/5 MAS 714 Hartmut Klauck
Theory of Computing Lecture 4/5 MAS 714 Hartmut Klauck How fast can we sort? There are deterministic algorithms that sort in worst case time O(n log n) Do better algorithms exist? Example [Andersson et
More informationJessica Su (some parts copied from CLRS / last quarter s notes)
1 Max flow Consider a directed graph G with positive edge weights c that define the capacity of each edge. We can identify two special nodes in G: the source node s and the sink node t. We want to find
More informationIn this lecture, we ll look at applications of duality to three problems:
Lecture 7 Duality Applications (Part II) In this lecture, we ll look at applications of duality to three problems: 1. Finding maximum spanning trees (MST). We know that Kruskal s algorithm finds this,
More informationMatchings in Graphs. Definition 1 Let G = (V, E) be a graph. M E is called as a matching of G if v V we have {e M : v is incident on e E} 1.
Lecturer: Scribe: Meena Mahajan Rajesh Chitnis Matchings in Graphs Meeting: 1 6th Jan 010 Most of the material in this lecture is taken from the book Fast Parallel Algorithms for Graph Matching Problems
More informationIntroduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.
Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Practice Final Practice Final Do not open this exam booklet until
More informationLecture 3. Brute Force
Lecture 3 Brute Force 1 Lecture Contents 1. Selection Sort and Bubble Sort 2. Sequential Search and Brute-Force String Matching 3. Closest-Pair and Convex-Hull Problems by Brute Force 4. Exhaustive Search
More informationChapter 3. Graphs. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 3 Graphs Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 3.1 Basic Definitions and Applications Undirected Graphs Undirected graph. G = (V, E) V = nodes. E
More informationLinear Programming Duality and Algorithms
COMPSCI 330: Design and Analysis of Algorithms 4/5/2016 and 4/7/2016 Linear Programming Duality and Algorithms Lecturer: Debmalya Panigrahi Scribe: Tianqi Song 1 Overview In this lecture, we will cover
More informationCSE 421 Applications of DFS(?) Topological sort
CSE 421 Applications of DFS(?) Topological sort Yin Tat Lee 1 Precedence Constraints In a directed graph, an edge (i, j) means task i must occur before task j. Applications Course prerequisite: course
More informationAlgorithm Design, Anal. & Imp., Homework 4 Solution
Algorithm Design, Anal. & Imp., Homework 4 Solution Note: The solution is for your personal use for this course. You are not allowed to post the solution in public place. There could be mistakes in the
More informationSolving problems on graph algorithms
Solving problems on graph algorithms Workshop Organized by: ACM Unit, Indian Statistical Institute, Kolkata. Tutorial-3 Date: 06.07.2017 Let G = (V, E) be an undirected graph. For a vertex v V, G {v} is
More informationPrelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer
Prelim 2 CS 2110, November 20, 2014, 7: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 informationCS599: Convex and Combinatorial Optimization Fall 2013 Lecture 14: Combinatorial Problems as Linear Programs I. Instructor: Shaddin Dughmi
CS599: Convex and Combinatorial Optimization Fall 2013 Lecture 14: Combinatorial Problems as Linear Programs I Instructor: Shaddin Dughmi Announcements Posted solutions to HW1 Today: Combinatorial problems
More informationCSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms. Lecturer: Shi Li
CSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Main Goal of Algorithm Design Design fast
More informationIntroduction to Mathematical Programming IE496. Final Review. Dr. Ted Ralphs
Introduction to Mathematical Programming IE496 Final Review Dr. Ted Ralphs IE496 Final Review 1 Course Wrap-up: Chapter 2 In the introduction, we discussed the general framework of mathematical modeling
More informationGraph Algorithms. Imran Rashid. Jan 16, University of Washington
Graph Algorithms Imran Rashid University of Washington Jan 16, 2008 1 / 26 Lecture Outline 1 BFS Bipartite Graphs 2 DAGs & Topological Ordering 3 DFS 2 / 26 Lecture Outline 1 BFS Bipartite Graphs 2 DAGs
More informationNotes for Lecture 24
U.C. Berkeley CS170: Intro to CS Theory Handout N24 Professor Luca Trevisan December 4, 2001 Notes for Lecture 24 1 Some NP-complete Numerical Problems 1.1 Subset Sum The Subset Sum problem is defined
More informationThe ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value
The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value 1 Possible implementations Sorted linear implementations o Appropriate if
More informationGraph Algorithms. Textbook reading. Chapter 3 Chapter 4. CSci 3110 Graph Algorithms 1/41
CSci 3110 Graph Algorithms 1/41 Graph Algorithms Textbook reading Chapter 3 Chapter 4 CSci 3110 Graph Algorithms 2/41 Overview Design principle: Learn the structure of a graph by systematic exploration
More informationFundamental Algorithms
Fundamental Algorithms Chapter 8: Graphs Jan Křetínský Winter 2017/18 Chapter 8: Graphs, Winter 2017/18 1 Graphs Definition (Graph) A graph G = (V, E) consists of a set V of vertices (nodes) and a set
More informationChapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1
Chapter 14 Graphs 2011 Pearson Addison-Wesley. All rights reserved 14 A-1 Terminology G = {V, E} A graph G consists of two sets A set V of vertices, or nodes A set E of edges A subgraph Consists of a subset
More information3.1 Basic Definitions and Applications. Chapter 3. Graphs. Undirected Graphs. Some Graph Applications
Chapter 3 31 Basic Definitions and Applications Graphs Slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley All rights reserved 1 Undirected Graphs Some Graph Applications Undirected graph G = (V,
More informationNon-context-Free Languages. CS215, Lecture 5 c
Non-context-Free Languages CS215 Lecture 5 c 2007 1 The Pumping Lemma Theorem (Pumping Lemma) Let be context-free There exists a positive integer divided into five pieces Proof for for each and Let and
More information22 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 informationMinimum spanning trees
Carlos Moreno cmoreno @ uwaterloo.ca EI-3 https://ece.uwaterloo.ca/~cmoreno/ece5 Standard reminder to set phones to silent/vibrate mode, please! During today's lesson: Introduce the notion of spanning
More informationCSE 21 Mathematics for Algorithm and System Analysis
CSE 21 Mathematics for Algorithm and System Analysis Unit 4: Basic Concepts in Graph Theory Section 3: Trees 1 Review : Decision Tree (DT-Section 1) Root of the decision tree on the left: 1 Leaves of the
More informationCSE 417 Network Flows (pt 4) Min Cost Flows
CSE 417 Network Flows (pt 4) Min Cost Flows Reminders > HW6 is due Monday Review of last three lectures > Defined the maximum flow problem find the feasible flow of maximum value flow is feasible if it
More informationMa/CS 6b Class 26: Art Galleries and Politicians
Ma/CS 6b Class 26: Art Galleries and Politicians By Adam Sheffer The Art Gallery Problem Problem. We wish to place security cameras at a gallery, such that they cover it completely. Every camera can cover
More information6. Lecture notes on matroid intersection
Massachusetts Institute of Technology 18.453: Combinatorial Optimization Michel X. Goemans May 2, 2017 6. Lecture notes on matroid intersection One nice feature about matroids is that a simple greedy algorithm
More informationExam 3 Practice Problems
Exam 3 Practice Problems HONOR CODE: You are allowed to work in groups on these problems, and also to talk to the TAs (the TAs have not seen these problems before and they do not know the solutions but
More information4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests
4 Basics of Trees Trees, actually acyclic connected simple graphs, are among the simplest graph classes. Despite their simplicity, they still have rich structure and many useful application, such as in
More informationCSE 100 Minimum Spanning Trees Prim s and Kruskal
CSE 100 Minimum Spanning Trees Prim s and Kruskal Your Turn The array of vertices, which include dist, prev, and done fields (initialize dist to INFINITY and done to false ): V0: dist= prev= done= adj:
More informationNotes for Recitation 9
6.042/18.062J Mathematics for Computer Science October 8, 2010 Tom Leighton and Marten van Dijk Notes for Recitation 9 1 Traveling Salesperson Problem Now we re going to talk about a famous optimization
More information3.1 Basic Definitions and Applications
Graphs hapter hapter Graphs. Basic efinitions and Applications Graph. G = (V, ) n V = nodes. n = edges between pairs of nodes. n aptures pairwise relationship between objects: Undirected graph represents
More informationThe Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation
The Shortest Path Problem jla,jc@imm.dtu.dk Department of Management Engineering Technical University of Denmark The Shortest Path Problem Given a directed network G = (V,E,w) for which the underlying
More informationChapter 16. Greedy Algorithms
Chapter 16. Greedy Algorithms Algorithms for optimization problems (minimization or maximization problems) typically go through a sequence of steps, with a set of choices at each step. A greedy algorithm
More informationUndirected Graphs. DSA - lecture 6 - T.U.Cluj-Napoca - M. Joldos 1
Undirected Graphs Terminology. Free Trees. Representations. Minimum Spanning Trees (algorithms: Prim, Kruskal). Graph Traversals (dfs, bfs). Articulation points & Biconnected Components. Graph Matching
More informationData Structures Brett Bernstein
Data Structures Brett Bernstein Final Review 1. Consider a binary tree of height k. (a) What is the maximum number of nodes? (b) What is the maximum number of leaves? (c) What is the minimum number of
More informationWeighted Graphs and Greedy Algorithms
COMP 182 Algorithmic Thinking Weighted Graphs and Greedy Algorithms Luay Nakhleh Computer Science Rice University Reading Material Chapter 10, Section 6 Chapter 11, Sections 4, 5 Weighted Graphs In many
More informationGraph Algorithms (part 3 of CSC 282),
Graph Algorithms (part of CSC 8), http://www.cs.rochester.edu/~stefanko/teaching/10cs8 1 Schedule Homework is due Thursday, Oct 1. The QUIZ will be on Tuesday, Oct. 6. List of algorithms covered in the
More information22 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 informationAlgorithm Design Methods. Some Methods Not Covered
Algorithm Design Methods Greedy method. Divide and conquer. Dynamic Programming. Backtracking. Branch and bound. Some Methods Not Covered Linear Programming. Integer Programming. Simulated Annealing. Neural
More informationGraph Algorithms (part 3 of CSC 282),
Graph Algorithms (part of CSC 8), http://www.cs.rochester.edu/~stefanko/teaching/11cs8 Homework problem sessions are in CSB 601, 6:1-7:1pm on Oct. (Wednesday), Oct. 1 (Wednesday), and on Oct. 19 (Wednesday);
More informationVertex Cover Approximations
CS124 Lecture 20 Heuristics can be useful in practice, but sometimes we would like to have guarantees. Approximation algorithms give guarantees. It is worth keeping in mind that sometimes approximation
More information3.1 Basic Definitions and Applications
Chapter 3 Graphs Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 3.1 Basic Definitions and Applications Undirected Graphs Undirected graph. G = (V, E) V = nodes. E
More informationIntroduction to Algorithms I
Summer School on Algorithms and Optimization Organized by: ACM Unit, ISI and IEEE CEDA. Tutorial II Date: 05.07.017 Introduction to Algorithms I (Q1) A binary tree is a rooted tree in which each node has
More informationDepartment of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I
MCA 312: Design and Analysis of Algorithms [Part I : Medium Answer Type Questions] UNIT I 1) What is an Algorithm? What is the need to study Algorithms? 2) Define: a) Time Efficiency b) Space Efficiency
More informationGraphs and Network Flows IE411. Lecture 21. Dr. Ted Ralphs
Graphs and Network Flows IE411 Lecture 21 Dr. Ted Ralphs IE411 Lecture 21 1 Combinatorial Optimization and Network Flows In general, most combinatorial optimization and integer programming problems are
More informationIntroduction to Graph Theory
Introduction to Graph Theory Tandy Warnow January 20, 2017 Graphs Tandy Warnow Graphs A graph G = (V, E) is an object that contains a vertex set V and an edge set E. We also write V (G) to denote the vertex
More informationLECTURES 3 and 4: Flows and Matchings
LECTURES 3 and 4: Flows and Matchings 1 Max Flow MAX FLOW (SP). Instance: Directed graph N = (V,A), two nodes s,t V, and capacities on the arcs c : A R +. A flow is a set of numbers on the arcs such that
More informationCSE 21 Summer 2017 Homework 4
CSE 21 Summer 201 Homework Key Concepts Minimum Spanning Trees, Directed Acyclic Graphs, Topological Sorting, Single source shortest paths, Counting, Basic probability principles, Independence, Linearity
More informationME 391Q Network Flow Programming
ME 9Q Network Flow Programming Final Exam, Summer 00. ( Points) The figure below shows an undirected network. The parameters on the edges are the edge lengths. Find the shortest path tree using Dijkstra
More informationDesign and Analysis of Algorithms
CSE, Winter 8 Design and Analysis of Algorithms Lecture : Graphs, DFS (Undirected, Directed), DAGs Class URL: http://vlsicad.ucsd.edu/courses/cse-w8/ Graphs Internet topology Graphs Gene-gene interactions
More informationCMSC351 - Fall 2014, Final Exam
CMSC351 - Fall 2014, Final Exam Type A WAIT FOR INSTRUCTIONS BEFORE BEGINNING HONOR PLEDGE: I pledge on my honor that I have not given or received any unauthorized assistance on this examination. Signature
More informationLecture 13: Minimum Spanning Trees Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY
Lecture 13: Minimum Spanning Trees Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Problem of the Day Your job is to
More informationTrees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017
12. Graphs and Trees 2 Aaron Tan 6 10 November 2017 1 10.5 Trees 2 Definition Definition Definition: Tree A graph is said to be circuit-free if, and only if, it has no circuits. A graph is called a tree
More informationmanaging an evolving set of connected components implementing a Union-Find data structure implementing Kruskal s algorithm
Spanning Trees 1 Spanning Trees the minimum spanning tree problem three greedy algorithms analysis of the algorithms 2 The Union-Find Data Structure managing an evolving set of connected components implementing
More informationOnline Algorithms. Lecture 11
Online Algorithms Lecture 11 Today DC on trees DC on arbitrary metrics DC on circle Scheduling K-server on trees Theorem The DC Algorithm is k-competitive for the k server problem on arbitrary tree metrics.
More informationProblem Set 2 Solutions
Design and Analysis of Algorithms February, 01 Massachusetts Institute of Technology 6.046J/18.410J Profs. Dana Moshkovitz and Bruce Tidor Handout 8 Problem Set Solutions This problem set is due at 9:00pm
More informationGraph Applications. Topological Sort Shortest Path Problems Spanning Trees. Data Structures 1 Graph Applications
Graph Applications Topological Sort Shortest Path Problems Spanning Trees Data Structures 1 Graph Applications Application: Topological Sort Given a set of jobs, courses, etc. with prerequisite constraints,
More informationMinimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem
Minimum Spanning Trees (Forests) Given an undirected graph G=(V,E) with each edge e having a weight w(e) : Find a subgraph T of G of minimum total weight s.t. every pair of vertices connected in G are
More information