1. Warshall's Algorithm
To which other algorithm from our course is Wasrhall's Transitive Closure algorithm most structurally similar?
A) Dijkstra
B) Floyd
C) Kadane
D) Karatsuba
E) Kruskal
F) Prim
G) Strassen
2. Powers of Adjacency Matrix
Which is true of an Adjacency Matrix of a directed graph raised to the k-th power (A^k)
A) A^k [i][j] = 1 if there is an edge of length k from vertex i to vertex j
B) A^k [i][j] = 1 if there is an edge of total cost k from vertex i to vertex j
C) A^k [i][j] = 1 if there is an path of length k from vertex i to vertex j
D) A^k [i][j] = 1 if there is an path of total cost k from vertex i to vertex j
E) None of the above
3. Transitive Closure by Matrix Operations
Which best describes how to determine the Transitive Closure by arithmetic operations on the Adjacency Matrix?
A) Compute A^(n-1)
B) Compute A^n
C) Compute A^0 + A^1 + ... + A^(n-1) where + is standard addition (integers)
D) Compute A^0 + A^1 + ... + A^(n-1) where + is boolean addition (true/false)
E) Compute A^1 + A^2 + ... + A^n where + is standard addition (integers)
F) Compute A^1 + A^2 + ... + A^n where + is boolean addition (true/false)
4. Transitive Closure using DFS (Directed Graph)
What best represents the the time complexity of computing the Transitive Closure of a Directed Graph, assuming representation by an Adjacency Table
A) O(V)
B) O(E)
C) O(V+E)
D) O(VE)
E) O(V^2)
F) O(E^2)
For brevity, we have sometimes dropped the set-cardinality signs, i.e. writing O(V) and O(E) respectively instead of the more proper O(|V|) and O(|E|).
Answer to 1)- (B).
warshall's algorithm is structurally similar to Floyd's all-pair shortest path algorithm. actually Floyd's algorithm is a bit of modification/improvement of warshall's algorithm and hence it is called Floyd-warshall algorithm. finding transitive closure of a di-graph requires iterating over the set of all the paths in the graph which is perfectly done by warshall's algo but if you want find shortest distance b/w all pairs of nodes of di-graph then you use modified warshall's algo called Floyd's algo( Floyd-warshall algo).
Answer to 2)- (C) A^k [i][j] = 1 if there is an path of length k from vertex i to vertex j.
It's standard definition of power of adjacency matrix of di-graph.
Answer to 3)- (F) Compute A^1 + A^2 + ... + A^n where + is boolean addition (true/false).
In order to compute transitive closure by matrix operations you use above formula. It actually finds if there exists a path of any length from 1 to n b/w given two nodes and returns true if it indeed exists which is what you call transitive closure from a node.
Answer to 4) - (C) O(V+E).
Depth first search algo takes O(V+E) time to finish the search.(used for transitive closure)
1. Warshall's Algorithm To which other algorithm from our course is Wasrhall's Transitive Closure algorithm most...
Problem 1: Dynamic Programming in DAG Let G(V,E), |V| = n, be a directed acyclic graph presented in adjacency list representation, where the vertices are labelled with numbers in the set {1, . . . , n}, and where (i, j) is and edge inplies i < j. Suppose also that each vertex has a positive value vi, 1 ≤ i ≤ n. Define the value of a path as the sum of the values of the vertices belonging to...
8, (10 pts) Show that given a directed graph G = (V,E) already stored in adjacency matrix form, determining if there is a vertex with in-degree n - 1 and out-degree 0 can be done in O(n) time where n is the number of vertices in V. 8, (10 pts) Show that given a directed graph G = (V,E) already stored in adjacency matrix form, determining if there is a vertex with in-degree n - 1 and out-degree 0 can...
Solve all parts please 5. In the following problems, recall that the adjacency matrix (or incidence matrix) for a simple graph with n vertices is an n x n matrix with entries that are all 0 or 1. The entries on the diagonal are all 0, and the entry in the ih row and jth column is 1 if there is an edge between vertex i and vertex j and is 0 if there is not an edge between vertex...
For a directed graph the in-degree of a vertex is the number of edges it has coming in to it, and the out- degree is the number of edges it has coming out. (a) Let G[i,j] be the adjacency matrix representation of a directed graph, write pseudocode (in the same detail as the text book) to compute the in-degree and out-degree of every vertex in the Page 1 of 2 CSC 375 Homework 3 Spring 2020 directed graph. Store results...
Problem 2: As we discussed in class, one can use an algorithm for computing all-pairs shortest paths to also compute the transitive closure of a graph. If using Floyd-Warshall for example, it is possible to do this in On") time (where as usual n is the number of nodes and m is the number of edges). Show how to compute the transitive closure of a directed graph in O(nm) time. For which type of graphs is this better than using...
2 Node removal Consider the following specifications: Algorithm 1 Removes node vk from graph G represented as an adjacency matrix A Require: A E {0,1}"x", kEN, k<n Ensure: A' E {0,1)(n-1)×(1-1) 1: function NODEREMOVAL(A,k) 2: ... 3: return A 4: end function The function accepts an adjacency matrix A, which represents a graph G, and an integer k, and returns adjacency matrix A', representing graph G', that is the result of removing node the k-th node us from G. Question:...
I have a Graph.java which I need to complete four methods in the java file: completeGraph(), valence(int vid), DFS(int start), and findPathBFS(int start, int end). I also have a JUnit test file GraphTest.java for you to check your code. Here is Graph.java: import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; /* Generic vertex class */ class Vertex<T> { public T data; public boolean visited; public Vertex() { data = null; visited = false; } public Vertex(T _data) { data =...
5. Suppose we are given an unweighted, directed graph G with n vertices (labelled 1 to n), and let M be the n × n adjacency matrix for G (that is, M (i,j-1 if directed edge (1J) is in G and 0 otherwise). a. Let the product of M with itself (M2) be defined, for 1 S i,jS n, as follows where "." is the Boolean and operator and "+" is the Boolean or operator. Given this definition what does...
3. The indegree of a vertex u is the number of incoming edges into u, .e, edges of the form (v,u) for some vertex v Consider the following algorithm that takes the adjacency list Alvi, v2, n] of a directed graph G as input and outputs an array containing all indegrees. An adjacency list Alvi, v.. /n] is an array indexed by the vertices in the graph. Each entry Alv, contains the list of neighbors of v) procedure Indegree(Alvi, v2,......
In this question, we will think about how to answer shortest path problems where we have more than just a single source and destination. Answer each of the following in English (not code or pseudocode). Each subpart requires at most a few sentences to answer. Answers significantly longer than required will not receive full credit You are in charge of routing ambulances to emergency calls. You have k ambulances in your fleet that are parked at different locations, and you...