2. Design a deterministic algorithm to solve the following
problem.
input: A directed acyclic graph G = (V, E) stored
using adjacency lists.
output: A Hamiltonian path, if such a path exists.
Otherwise, return NONE.
Your algorithm must take O(|V| + |E|) time. You must describe your
algorithm in plain English (no pseudocode) and you must explain why
the running time of your algorithm is O(|V| + |E|). Maximum half a
page
To find if there is a Hamiltonian path in a DAG(or directed acyclic graph), we will use the concept of topological sorting. In topological sorting we order the vertices of the graph in such a way that for all the directed edges xy present in the DAG, vertex 'x' comes before vertex 'y' in the ordering. Topological sort in DAG can be computed in O(|V| + |E|) time. Topological sort can be performed easily in O(|V| + |E|) by repeatedly computing indegrees of vertices. After performing the topological sort we just need to check that if there exists an edge between each of the consecutive vertices in the topological order(This can be done in O(|V| + |E|) time by amortized analysis). If it is so, then there exists a hamiltonian path else not.
2. Design a deterministic algorithm to solve the following problem. input: A directed acyclic graph G...
Design an efficient algorithm to find the longest path in a directed acyclic graph. (Must handle general real-valued weights on the edges, including negative values.) Use C, Java, or Python.
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...
114points Let G- (V,E) be a directed graph. The in-degree of a vertex v is the number of edges (a) Design an algorithm (give pseudocode) that, given a vertex v EV, computes the in-degree of v under (b) Design an algorithm (give pseudocode) that, given a vertex v E V, computes the in-degree of v incident into v. the assumption that G is represented by an adjacency list. Give an analysis of your algorithm. under the assumption that G is...
Viterbi algorithm We can use dynamic programming on a directed graph G = (V, E) for speech recognition. Each edge (u, v) in E is labeled with a sound s(u, v) from a finite set S of sounds. The labeled graph is a formal model of a person speaking a restricted language. Each path in the graph starting from a distinguished vertex v0 in V corresponds to a possible sequence of sounds produced by the model. The label of a...
Consider a directed acyclic graph G = (V, E) without edge lengths and a start vertex s E V. (Recall, the length of a path in an graph without edge lengths is given by the number of edges on that path). Someone claims that the following greedy algorithm will always find longest path in the graph G starting from s. path = [8] Ucurrent = s topologically sort the vertices V of G. forall v EV in topological order do...
PRINCETON UNIVERSITY 12. Algorithm design. (8 points) Given an edge-weighted digraph G the bottleneck capacity of a path is the minimum weight of an edge on the path. For each part elow, give a crisp and concise English description of your algorithm in the space provided. Your ansuer will be graded on correctness, eficieney, clarity, and conciseness (a) Given an edge-weighted digraph G, two distinguished vertices s and t, and a threshold value T, design an algorithm to find any...
please solve this one 5-12. [5] The square of a directed graph G = (V,E) is the graph G2 = (V,E2) such that (u,w) ∈ E2 iff there exists v ∈ V such that (u,v) ∈ E and (v,w) ∈ E; i.e., there is a path of exactly two edges from u to w. Give efficient algorithms for both adjacency lists and matrices.
You are given an unweighted DAG (Directed Acyclic Graph) G, along with a start node s and a target node t. Design a linear time (i.e., runtime O(IV+ EI)) dynamic programming algorithm for computing the number of all paths (not necessarily shortest) from s to t.
Please show your work 3. Give an efficient algorithm that takes as input a directed graph G-(V,E) with edges labeled with either 0 or 1, and vertices s and t that ouputs TRUE if and only if there is a path (not necessarily simple) that goes from s to t such that the binary sequence of edges in the path avoids the substring "11" and outputs FALSE otherwise. (For example, the string 10100010 avoids 11 but the string 00101101110 does...
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...