Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Question
Chapter 16.1, Problem 4E
Program Plan Intro
To provide an efficient greedy
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In hill-climbing algorithms there are steps that make lots of progress and steps that make very little progress. For example, the first iteration on the input given might find a path through the augmentation graph through which a flow of 30 can be added. It might, however, find the path through which only a flow of 2 can be added. How bad might the running time be when the computation is unlucky enough to always take the worst legal step allowed by the algorithm? Start by taking the step that increases the flow by 2 for the input. Then continue to take the worst possible step. You could draw out each and every step, but it is better to use this opportunity to use loop invariants. What does the flow look like after i iterations? Repeat this process on the same graph except that the four edges forming the square now have capacities 1,000,000,000,000,000 and the crossover edge has capacity 1. (Also move t to c or give that last edge a large capacity.)1. What is the worst case number of…
The given inputs consist of two nodes (s, t) and a directed graph G = (V, E). In addition, each edge of the graph is either blue or red. The goal is to find a path from point s to point t such that red edges always follow blue edges. There need not be any red or blue borders on the route, but if there are, the red ones should follow the blue ones. Develop an algorithm that does the task in O(n + m) time and analyze its performance.
The graph-coloring problem is usually stated as the vertex-coloring problem: assign the smallest number of colors to vertices of a given graph so that no two adjacent vertices are the same color. Consider the edge-coloring problem: assign the smallest number of colors possible to edges of a given graph so that no two edges with the same end point are the same color. Explain how the edge-coloring problem can be polynomial reduced to a vertex-coloring problem. Give an example.
Chapter 16 Solutions
Introduction to Algorithms
Ch. 16.1 - Prob. 1ECh. 16.1 - Prob. 2ECh. 16.1 - Prob. 3ECh. 16.1 - Prob. 4ECh. 16.1 - Prob. 5ECh. 16.2 - Prob. 1ECh. 16.2 - Prob. 2ECh. 16.2 - Prob. 3ECh. 16.2 - Prob. 4ECh. 16.2 - Prob. 5E
Ch. 16.2 - Prob. 6ECh. 16.2 - Prob. 7ECh. 16.3 - Prob. 1ECh. 16.3 - Prob. 2ECh. 16.3 - Prob. 3ECh. 16.3 - Prob. 4ECh. 16.3 - Prob. 5ECh. 16.3 - Prob. 6ECh. 16.3 - Prob. 7ECh. 16.3 - Prob. 8ECh. 16.3 - Prob. 9ECh. 16.4 - Prob. 1ECh. 16.4 - Prob. 2ECh. 16.4 - Prob. 3ECh. 16.4 - Prob. 4ECh. 16.4 - Prob. 5ECh. 16.5 - Prob. 1ECh. 16.5 - Prob. 2ECh. 16 - Prob. 1PCh. 16 - Prob. 2PCh. 16 - Prob. 3PCh. 16 - Prob. 4PCh. 16 - Prob. 5P
Knowledge Booster
Similar questions
- In this question you will explore Graph Colouring algorithms. Given a graph G, we say that G is k-colourable if every vertex of G can be assigned one of k colours so that for every pair u, v of adjacent vertices, u and v are assigned different colours. The chromatic number of a graph G, denoted by χ(G), is the smallest integer k for which graph G is k-colorable. To show that χ(G) = k, you must show that the graph is k-colourable and that the graph is not (k − 1)-colourable. Question: It is NP-complete to determine whether an arbitrary graph has chromatic number k, where k ≥ 3. However, determining whether an arbitrary graph has chromatic number 2 is in P. Given a graph G on n vertices, create an algorithm that will return TRUE if χ(G) = 2 and FALSE if χ(G) 6= 2. Clearly explain how your algorithm works, why it guarantees the correct output, and determine the running time of your algorithm.arrow_forwardCreate a simple greedy algorithm for colouring the vertices of any graph G, ideally using as few colours as possible. Explain how your algorithm works, i.e., the order in which your algorithm chooses the vertices of a given graph, and how a colour is assigned to each vertex. Apply your algorithm to the graph in (a). How many colours did your algorithm use?arrow_forwardYou are organizing a programming competition, where contestants implement Dijkstra's algorithm. Given adirected graph G = (V, E) with integer-weight edges and a starting vertex s ∈ V , their programs are supposedto output triplets (v, v.d, v.π) for each vertex v ∈ V . Design an O(V +E) time algorithm that takes as inputthe original graph G in both adjacency matrix (G.M) and adjacency list (G.Adj) representations, startingvertex s, and the output of a contestant's program (given as an array A of triplets), and returns whetherA is the correct output for G. Write down the pseudocode for your algorithm, explain why it correctlyveries the output, and analyze your algorithm's running time. You may assume that all edge weights of the input graph provided to the contestantsare nonnegative and A (the output of their programs) is in the valid format, i.e., you don't need to verifythat A is actually an array of triplets, with v and v.π being valid vertices and v.d being an integer.Can you…arrow_forward
- The edge-coloring problem is to color the edges of a graph with the fewest number of colors in such a way any two edges that share a vertex have different colors . You are given the algorithm that colors a graph with at most d+1 colors if the graph has a vertex with maximum degree d. You do not need to know how the algorithm works. Prove that this algorithm is a 2-approximation to the edge coloring problem. You may assume that d≥1. There are no decision problems in NP-hard class. True or Falsearrow_forwardWe recollect that Kruskal's Algorithm is used to find the minimum spanning tree in a weighted graph. Given a weighted undirected graph G = (V , E, W), with n vertices/nodes, the algorithm will first sort the edges in E according to their weights. It will then select (n-1) edges with smallest weights that do not form a cycle. (A cycle in a graph is a path along the edges of a graph that starts at a node and ends at the same node after visiting at least one other node and not traversing any of the edges more than once.) Use Kruskal's Algorithm to nd the weight of the minimum spanning tree for the following graph.arrow_forwardSuppose you have a graph G with 6 vertices and 7 edges, and you are given the following information: The degree of vertex 1 is 3. The degree of vertex 2 is 4. The degree of vertex 3 is 2. The degree of vertex 4 is 3. The degree of vertex 5 is 2. The degree of vertex 6 is 2. What is the minimum possible number of cycles in the graph G?arrow_forward
- We are given an undirected graph, that is connected. We're also given that each edge is associated with a positive weight. Now, we want to make this graph acyclic by removing some edges. Find this set of edges by designing an algorithm. Note: this edge set should have the smallest total weight out of other potential edge set solutions. The algorithm should run in O((m + n)log n) time.arrow_forwardWe know that when we have a graph with negative edge costs, Dijkstra’s algorithm is not guaranteed to work. (a) Does Dijkstra’s algorithm ever work when some of the edge costs are negative? Explain why or why not. (b) Find an algorithm that will always find a shortest path between two nodes, under the assumption that at most one edge in the input has a negative weight. Your algorithm should run in time O(m log n), where m is the number of edges and n is the number of nodes. That is, the runnning time should be at most a constant factor slower than Dijkstra’s algorithm. To be clear, your algorithm takes as input (i) a directed graph, G, given in adjacency list form. (ii) a weight function f, which, given two adjacent nodes, v,w, returns the weight of the edge between them. For non-adjacent nodes v,w, you may assume f(v,w) returns +1. (iii) a pair of nodes, s, t. If the input contains a negative cycle, you should find one and output it. Otherwise, if the graph contains at least one…arrow_forwardSuppose you are given a connected undirected weighted graph G with a particular vertex s designated as the source. It is also given to you that weight of every edge in this graph is equal to 1 or 2. You need to find the shortest path from source s to every other vertex in the graph. This could be done using Dijkstra’s algorithm but you are told that you must solve this problem using a breadth-first search strategy. Design a linear time algorithm (Θ(|V | + |E|)) that will solve your problem. Show that running time of your modifications is O(|V | + |E|). Detailed pseudocode is required. Hint: You may modify the input graph (as long as you still get the correct shortest path distances).arrow_forward
- Suppose you have a graph with 100 nodes and 500 edges and you want to find the shortest path between two nodes using Dijkstra's algorithm. What is the time complexity of this operation?arrow_forwardSuppose you are given a directed graph G on n vertices, each of which is assigned a colour. (In this problem, both endpoints of an edge can have the same colour.) Give an efficient algorithm to find the length of the longest monochromatic directed walk in G. (In a walk we can revisit vertices and recross edges, whereas in a path we cannot.) Your algorithm should return "undefined" if there is a directed cycle whose vertices are all the same colour.arrow_forwardGiven N cities represented as vertices V₁, V2, un on an undirected graph (i.e., each edge can be traversed in both directions). The graph is fully-connected where the edge eij connecting any two vertices vį and vj is the straight-line distance between these two cities. We want to search for the shortest path from v₁ (the source) to VN (the destination). ... Assume that all edges have different values, and €₁,7 has the largest value among the edges. That is, the source and destination have the largest straight-line distance. Compare the lists of explored vertices when we run the uniform-cost search and the A* search for this problem. Hint: The straight-line distance is the shortest path between any two cities. If you do not know how to start, try to run the algorithms by hand on some small cases first; but remember to make sure your graphs satisfy the conditions in the question.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education