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
Concept explainers
Question
Chapter 23, Problem 2P
(a)
Program Plan Intro
To prove that
(b)
Program Plan Intro
To prove that
(c)
Program Plan Intro
To show the implementation of MST-REDUCE to make it run in O ( E ).
(d)
Program Plan Intro
To argue that the overall running time of k phrase is O ( kE ).
(e)
Program Plan Intro
To argue that the choice of k that is the number of phrases of MST-REDUCE minimizes the overall asymptotic running time.
(f)
Program Plan Intro
To find the value for which | E |, Prim’s algorithm with pre-processing asymptotically beats Prim’s algorithm without preprocessing.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Given an undirected weighted graph G with n nodes and m edges, and we have used Prim’s algorithm to construct a minimum spanning tree T. Suppose the weight of one of the tree edge ((u, v) ∈ T) is changed from w to w′, design an algorithm to verify whether T is still a minimum spanning tree. Your algorithm should run in O(m) time, and explain why your algorithm is correct. You can assume all the weights are distinct. (Hint: When an edge is removed, nodes of T will break into two groups. Which edge should we choose in the cut of these two groups?)
Write a pseudocode to find all pairs shortest paths using the technique used in Bellman-Ford's algorithm so that it will produce the same matrices like Floyd-Warshall algorithm produces. Also provide the algorithm to print the paths for a source vertex and a destination vertex. For the pseudocode consider the following definition of the graph - Given a weighted directed graph, G = (V, E) with a weight function wthat maps edges to real-valued weights. w(u, v) denotes the weight of an edge (u, v). Assume vertices are labeled using numbers from1 to n if there are n vertices.
The Floyd-Warshall algorithm is a dynamic algorithm for searching the shortest path in a
graph. Each vertex pair has its assigned weight. You are asked to draw the initial directed
graph and show the tables for each vertex from Mo to Ms by finding all the shortest paths.
Below is the algorithm as a guide.
Algorithm 1: Pseudocode of Floyd-Warshall Algorithm
Data: A directed weighted graph G(V, E)
Result: Shortest path between each pair of vertices in G
for each de V do
| distance|d][d] «= 0;
end
for each edge (s, p) € E do
| distance[s][p] + weight(s, p);
end
n = cardinality(V);
for k = 1 to n do
for i = 1 to n do
for j = 1 to n do
if distancefi][j] > distance/i][k] + distance/k][j] then
| distance i]lj] + distancefi|[k] + distance/k|[j];
end
end
end
end
Consider the relation R = {(1,4) =4, (2,1)=3, (2,5)=-3, (3,4)=2, (4,2)=1, (4,3)=1, (5,4)=2 } on
A = (1,2,3,4,5) solve the Floyd-Warshall Algorithm.
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- We are given a simple connected undirected graph G = (V, E) with edge costs c : E → R+. We would like to find a spanning binary tree T rooted a given node r ∈ T such that T has minimum weight. Consider the following modifiedPrim algorithm that works similar to Prim’s MST algorithm: We maintain a tree T (initially set to be r by itself) and in each iteration of the algorithm, we grow T by attaching a new node T in the cheapest possible way such that we do not violate the binary constraint; if it is not possible to grow the tree, we declare the instance to be infeasible.1: function modifiedPrim(G=(V, E), r)2: T ← {r}3: while |T| < |V| do4: S ← {u ∈ V : u ∈ T and |children(u)| < 2}5: R ← {u ∈ V : u ∈/ T}6: if ∃ (u, v) ∈ E with u ∈ S and v ∈ R then7: let (u, v) be the minimum cost such edge8: Add (u, v) to T9: else10: return infeasible11: return THow would you either prove the correctness of modifiedPrim or provide a counter-example where it fails to return the correct answer.arrow_forwardLet G = (V, E) be an undirected and connected graph, where each edge (u, v) E E has a weight wt(u, v) > 0. Moreover, assume that all weights are equal. (a) G. The running time of your algorithm must be faster than the running time of Kruskal's algorithm. Design an algorithm to compute a minimum spanning tree (MST) of You must describe your algorithm in plain English (no pseudocode). You must write the running time of your algorithm and explain why you get this running time. (b) In at most 50 words, explain why your algorithm is correct.arrow_forwardThe Triangle Vertex Deletion problem is defined as follows: Given: an undirected graph G = (V, E) , with IVI=n, and an integer k>= 0. Is there a set of at most k vertices in G whose deletion results in deleting all triangles in G? (a) Give a simple recursive backtracking algorithm that runs in O(3^k * ( p(n))) where p(n) is a low-degree polynomial corresponding to the time needed to determine whether a certain vertex belongs to a triangle in G. (b) Selecting a vertex that belong to two different triangles can result in a better algorithm. Using this idea, provide an improved algorithm whose running time is O((2.562^n) * p(n)) where 2.652 is the positive root of the equation x^2=x+4arrow_forward
- The minimum vertex cover problem is stated as follows: Given an undirected graph G = (V, E) with N vertices and M edges. Find a minimal size subset of vertices X from V such that every edge (u, v) in E is incident on at least one vertex in X. In other words you want to find a minimal subset of vertices that together touch all the edges. For example, the set of vertices X = {a,c} constitutes a minimum vertex cover for the following graph: a---b---c---g d e Formulate the minimum vertex cover problem as a Genetic Algorithm or another form of evolutionary optimization. You may use binary representation, OR any repre- sentation that you think is more appropriate. you should specify: • A fitness function. Give 3 examples of individuals and their fitness values if you are solving the above example. • A set of mutation and/or crossover and/or repair operators. Intelligent operators that are suitable for this particular domain will earn more credit. • A termination criterion for the…arrow_forward2. The greedy algorithm for the vertex cover problem picks a highest degree vertex v, includes v in the cover, deletes all edges incident to v, and repeats until there are no edges left. Show that this algorithm is not a c-approximation algorithm for any c. Hint: consider a bipartite graph G = (A, B, E) with |A| = n and B ULBi, where |B;| = [n/i]. Vertices in B; have degree i, and the neigh- borhoods of different vertices are disjoint.arrow_forwardLet G be a graph, where each edge has a weight. A spanning tree is a set of edges that connects all the vertices together, so that there exists a path between any pair of vertices in the graph. A minimum-weight spanning tree is a spanning tree whose sum of edge weights is as small as possible. Last week we saw how Kruskal's Algorithm can be applied to any graph to generate a minimum-weight spanning tree. In this question, you will apply Prim's Algorithm on the graph below. You must start with vertex A. H 4 4 1 3 J 2 C 10 4 8 B 9 F 18 8 There are nine edges in the spanning tree produced by Prim's Algorithm, including AB, BC, and IJ. Determine the exact order in which these nine edges are added to form the minimum-weight spanning tree. 3.arrow_forward
- Let G be a graph, where each edge has a weight. A spanning tree is a set of edges that connects all the vertices together, so that there exists a path between any pair of vertices in the graph. A minimum-weight spanning tree is a spanning tree whose sum of edge weights is as small as possible. Last week we saw how Kruskal's Algorithm can be applied to any graph to generate a minimum-weight spanning tree. In this question, you will apply Prim's Algorithm on the same graph from the previous quiz. You must start with vertex A. H 4 G D J 9 4 7 10 6 8 В F A 18 E There are nine edges in the spanning tree produced by Prim's Algorithm, including AB, BC, and IJ. Determine the exact order in which these nine edges are added to form the minimum-weight spanning tree. 3.arrow_forwardFill in the blank Dijkstra's algorithm works because, on every shortest path p from a source vertex u to a target vertex v, there is a (predecessor) vertex w in p immediately before v such that removing v from p yields the shortest path from u to w. In other words, the path through the previous vertex is also the shortest path. Thus, choosing an edge from the previous vertex that brings us to v with the __ cost always yields the shortest path to v.arrow_forwardThe Algorithm of AlgebraThe adjacency matrix A of a graph G = is used by the algebraic BFS algorithm (V, E).First, we create a vector x with all zeros except for the index of the source vertex s that we wish to use as the starting point for the algorithm; next, we create the matrix A = A+ I; last, AT x chooses all nodes that are at a distance of 1 (level 1) from the source vertex. The vertices with the fewest number of hops are obtained by multiplying the vector x by the matrix A2. As a rule, the product Ak x will produce neighbours that are at most k hops distant, and the multiplication should be done in a boolean manner as in the algorithm shown below. Algorithm for Algebraic BFS1: Input : Adjacency matrix An,n of a graph G = (V, E) connected, unweighted graph G and asource vertex s2: Output : N, visited, levels a matrix that shows level i vertices at its column i, the visitedvertices in sequence and their levels3: x[n] ← 04: x[s] ← 15: A ← A + I6: for i = 1 to n do7: N ← AT · x8:…arrow_forward
- Given a graph G = (V, E), let us call G an almost-tree if G is connected and G contains at most n + 12 edges, where n = |V |. Each edge of G has an associated cost, and we may assume that all edge costs are distinct. Describe an algorithm that takes as input an almost-tree G and returns a minimum spanning tree of G. Your algorithm should run in O(n) time.arrow_forwardP R O B L E M D E S C R I P T I O N :1. As described in the reading and lecture, an adjacency matrix for a graph with n verticesnumber 0, 1, …, n – 1 is an n by n array matrix such that matrix[i][j] is 1 (or true) ifthere is an edge from vertex i to vertex j, and 0 (or false) otherwise.2. In this assignment, you will implement the methods identified in the stub code below insupport of the Graph ADT that uses an adjacency matrix to represent an undirected,unweighted graph with no self-loops.import java.util.*; // for all needed JCF classespublic class Graph { private int[][] matrix;// the adjacency matrix of the graph. // Creates an n x n array with all values initialized to 0. public Graph(int n) {// your code here } // end constructor // This method returns the number of nodes in the graph. public int getNumVertices() {// your code here } // end getNumVertices // This method returns the number of edges in the graph. public int getNumEdges() {// your code here } // end getNumEdges //…arrow_forwardLet G be a graph with V vertices and E edges. One can implement Kruskal's Algorithm to run in O(E log V) time, and Prim's Algorithm to run in O(E + V log V) time. If G is a dense graph with an extremely large number of vertices, determine which algorithm would output the minimum-weight spanning tree more quickly. Clearly justify your answer.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