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 25, Problem 2P
(a)
Program Plan Intro
To show the running time complexity of INSERT, EXTRACT-MIN, DECREASE-KEY in d -array min-heap of ‘ n’ elements and if the value of
(b)
Program Plan Intro
To find the shortest path problem solution if the graph does not contains negative weight in O ( E ) time.
(c)
Program Plan Intro
To find the shortest path problem solution if the graph does not contains negative weight.
(d)
Program Plan Intro
To find the shortest path problem solution if the graph contains negative weights but not negative weight cycle.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The 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+4
Let 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.
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.
Chapter 25 Solutions
Introduction to Algorithms
Ch. 25.1 - Prob. 1ECh. 25.1 - Prob. 2ECh. 25.1 - Prob. 3ECh. 25.1 - Prob. 4ECh. 25.1 - Prob. 5ECh. 25.1 - Prob. 6ECh. 25.1 - Prob. 7ECh. 25.1 - Prob. 8ECh. 25.1 - Prob. 9ECh. 25.1 - Prob. 10E
Ch. 25.2 - Prob. 1ECh. 25.2 - Prob. 2ECh. 25.2 - Prob. 3ECh. 25.2 - Prob. 4ECh. 25.2 - Prob. 5ECh. 25.2 - Prob. 6ECh. 25.2 - Prob. 7ECh. 25.2 - Prob. 8ECh. 25.2 - Prob. 9ECh. 25.3 - Prob. 1ECh. 25.3 - Prob. 2ECh. 25.3 - Prob. 3ECh. 25.3 - Prob. 4ECh. 25.3 - Prob. 5ECh. 25.3 - Prob. 6ECh. 25 - Prob. 1PCh. 25 - Prob. 2P
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
- Most graph algorithms that take an n×n adjacency-matrix representation as input require at least time O(n^2), but there are some exceptions. Show how to determine whether a simple directed graph G contains a universal sink, that is, a vertex with in degree n − 1 and out-degree 0, in time O(n) given an n × n adjacency matrix for G. (A vertex v has indegree k if there are precisely k edges of the form (u, v), and has outdegree k if there are precisely k edges of the form (v, u).)arrow_forwardThe following solution designed from a problem-solving strategy has been proposed for finding a minimum spanning tree (MST) in a connected weighted graph G: Randomly divide the vertices in the graph into two subsets to form two connected weighted subgraphs with equal number of vertices or differing by at most Each subgraph contains all the edges whose vertices both belong to the subgraph’s vertex set. Find a MST for each subgraph using Kruskal’s Connect the two MSTs by choosing an edge with minimum wight amongst those edges connecting Is the final minimum spanning tree found a MST for G? Justify your answer.arrow_forwardLet G = (V, E) be a directed graph. Assume that each edge ij belongs to E has a non-negative weightw(i, j) associated with it. Design a dynamic programming algorithm (Floyd-Warshal) for computing a shortest path between any vertex pair. You should define all necessary terms and then, write a recurrence relation. What is the time complexity of your algorithm.arrow_forward
- 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_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_forwardGiven an undirected graph G = <V,E>, a vertex cover is a subset of vertices S V such that for each edge (u,v) belongs to E, either u S or v S or both. The Vertex Cover Problem is to find minimum size of the set S. Consider the following algorithm to Vertex Cover Problem: (1) Initialize the result as {} (2) Consider a set of all edges in given graph. Let the set be E’. (3) Do following while E’ is not empty ...a) Pick an arbitrary edge (u,v) from set E’ and add u and v to result ...b) Remove all edges from E which are either incident on u or v. (4) Return result. It claim that this algorithm is exact for undirected connected graphs. Is this claim True or False? Justify the answer.arrow_forward
- adgis s o (6): = min { d(v) Ive V3 is the minimum degree of G. 0612 Z9Nto JJ V PO Go is called K-connected if IGI>K and GIX is connected for every set x CV with 1X1arrow_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_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 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_forwardPlease help with algorithm no coding neededarrow_forwardLet G = (V, E) be a connected, undirected graph, and let s be a fixed vertex in G. Let TB be the spanning tree of G found by a bread first search starting from s, and similarly TD the spanning tree found by depth first search, also starting at s. (As in problem 1, these trees are just sets of edges; the order in which they were traversed by the respective algorithms is irrelevant.) Using facts, prove that TB = TD if and only if TB = TD = E, i.e., G is itself a tree.arrow_forwardLet G be a directed acyclic graph. You would like to know if graph G contains directed path that goes through every vertex exactly once. Give an algorithm that tests this property. Provide justification of the correctness and analyze running time complexity of your algorithm. Your algorithm must have a running time in O(|V | + |E|). Detailed pseudocode is required.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_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