Develop an algorithm which takes node-node incidence matrix as an input and determines whether the graph is connected or not.
// The adjacency matrix and visited array have global
declaration
void DFS(int i) {
visited[i] = true;
for (Integer n : adj[i]) {
if (!visited[n])
DFS(n);
}
}
boolean Connectivity() {
// assume you start counting with zero
DFS(0); boolean f=true;
// check each element in the visited array if any is false
connectivity does not exist.
for (int j = 0; j < nodecount; ++j)
if (!visited[j]) {
flag = false;
break;
}
return flag;
}
Develop an algorithm which takes node-node incidence matrix as an input and determines whether the graph...
Dijkstra’s Algorithm: You have to implement the Dijkstra’s algorithm and apply it on the graph provided below. You have to take the input from the user as an adjacency matrix representing the graph, the source, the destination. Then you have to apply the Dijkstra’s algorithm to find the shortest path from the source and the destination, and find the shortest route between the source and the destination. For the input you have to read it from a file. It will...
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,...
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:...
can someone help me with this problem? thanks Prove that there is no algorithm that determines whether an arbitrary Turing machine halts when run with the input string 101. Prove that there is no algorithm that determines whether an arbitrary Turing machine halts when run with the input string 101.
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...
ALGORITHM DESIGN Given a connected weighted graph, give a scheme to find the farthest node from a given source node. Note that you do not have to start from scratch, but use a known standard algorithm. Hint: Make sure use of a known algorithm for finding the shortest paths.
a. Use pseudocode to specify a brute-force algorithm that takes as input a list of n positive integers and determines whether there are two distinct elements of the list that have as their sum a third element of the list. That is, whether there exists i, j.k such that iヂj, i关k,j关k and ai + aj = ak. The algorithm should loop through all triples of elements of the list checking whether the sum of the first two is the third...
Matlab question Takes an n × n matrix A and n × 1 vector b as input. . Checks whether the given matrix is square, if not prints an error. . Solves the linear system defined by A and b with the LU-method. .Outputs the solution and the residue of the solution. . Has comments in every line of code. Takes an n × n matrix A and n × 1 vector b as input. . Checks whether the given...
Write a function which takes as input a matrix and outputs a matrix in which each positive element is doubled. For instance, for the matrix A=[3, -1; -2, 4], and output should be [6,-1; -2,8].
Give an efficient algorithm that takes a directed graph G = (V, E) and two vertices u, v E V, and determines if there are at least two edge-disjoint paths in G from u to v. i.e., your algorithm should determine whether there are at least two paths from u to v in G that have no edges in common. Argue your algorithm's correctness and analyze its time complexity.