Now consider time taken by the code:
-------------------------------------------------------------------------------------------------------------
while(v
V) // This will execute V times
{
for all u
Adj[v]) // This will execute (V -1) times // one vertex
may be adjacent to max (V -1) remain vertex
{
boo(V); // This will take V3 times
}
}
---------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
So Total Run time = time complexity + space complexity:
Run time of code for the given graph when graph is stored as
adjacency
Matrix Representation:
Question 6 15pt Given undirected positive edge weight graph G(V.E) and boo(m) = m3 while (v...
Question 6 15pt Given undirected positive edge weight graph G(V.E) and boo(m) = m3 while (v € VX for all u € Adj[v]) { boo(V): ) ) What is the run-time of the code above given the Graph is store as adj. list? What is the run-time of the code above given the Graph is store as adj. matrix? Please explain your answer.
IN JAVA Given is a weighted undirected graph G = (V, E) with positive weights and a subset of its edges F E. ⊆ E. An F-containing spanning tree of G is a spanning tree that contains all edges from F (there might be other edges as well). Give an algorithm that finds the cost of the minimum-cost F-containing spanning tree of G and runs in time O(m log n) or O(n2). Input: The first line of the text file...
NP-completeness. We are given an undirected graph where each edge has a positive weight. Given (k, alpha), the problem asks whether there is a subgraph with k nodes such that the total weight of the edges in the subgraph is at least alpha. Prove this problem is NP-Complete.
You are given an undirected graph G = (V, E) with positive weights on the edges. If the edge weights are distinct, then there is only one MST, so both Prim’s and Kruskal’s algorithms will find the same MST. If some of the edge weights are the same, then there can be several MSTs and the two algorithms could find different MSTs. Describe a method that forces Prim’s algorithm to find the same MST of G that Kruskal’s algorithm finds.
2. Let G = (V, E) be an undirected connected graph with n vertices and with an edge-weight function w : E → Z. An edge (u, v) ∈ E is sparkling if it is contained in some minimum spanning tree (MST) of G. The computational problem is to return the set of all sparkling edges in E. Describe an efficient algorithm for this computational problem. You do not need to use pseudocode. What is the asymptotic time complexity of...
Question 1: Given an undirected connected graph so that every edge belongs to at least one simple cycle (a cycle is simple if be vertex appears more than once). Show that we can give a direction to every edge so that the graph will be strongly connected. Question 2: Given a graph G(V, E) a set I is an independent set if for every uv el, u #v, uv & E. A Matching is a collection of edges {ei} so...
Reachability. You are given a connected undirected graph G = (V, E ) as an adjacency list. The graph G might not be connected. You want to fill-in a two-dimensional array R[,] so that R[u,v] is 1 if there is a path from vertex u to vertex v. If no such path exists, then R[u,v] is 0. From this two-dimensional array, you can determine whether vertex u is reachable from vertex v in O(1) time for any pair of vertices...
Help !! I need help with Depth-First Search using an
undirected graph.
Write a program, IN JAVA, to implement the
depth-first search algorithm using the pseudocode given.
Write a driver program, which reads input file mediumG.txt as an
undirected graph and runs
the depth-first search algorithm to find paths to all the other
vertices considering 0 as the
source. This driver program should display the paths in the
following manner:
0 to ‘v’: list of all the vertices traversed to...
Consider an unweighted, undirected graph G = 〈V, E). The neighbourhood of a node u E V in the graph is the set of all nodes that are adjacent (or directly connected) to v. Subsequently, we can define the neighbourhood degree of the node v as the sum of the degrees of all its neighbours (those nodes that are directly connects to v) (a) Design an algorithm that returns a list containing the neighbourhood degree for each node v V,...
This question needs to be done using pseudocode (not any
particular programming language). Thanks
Consider an unweighted, undirected graph G = 〈V, E). The neighbourhood of a node u E V in the graph is the set of all nodes that are adjacent (or directly connected) to v. Subsequently, we can define the neighbourhood degree of the node v as the sum of the degrees of all its neighbours (those nodes that are directly connects to v) (a) Design an...