Remarks: All the graphs here are without self loops and parallel edges, and anti-parallel edges. When we speak of a flow network, we mean there are capacities c(e) ? 0 on the edges, the graph G is directed with a source s and a destination t. In all the algorithms, always explain their correctness and analyze their complexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit.
• Question 3: Given an undirected graph, give an algorithm that for every v returns the number of connected componnents in G ? v.
dfs(node u) for each node v connected to u : if v is not visited : visited[v] = true dfs(v) for each node u: if u is not visited : visited[u] = true connected_component += 1 dfs(u)
Remarks: All the graphs here are without self loops and parallel edges, and anti-parallel edges. When...
Let G = (V, E) be an undirected graph, with no parallel edges or self-loops. Let |vl = n and IEI = m. Prove by induction that 2m S n -n for all n 2 1 5.
Problem 5. (12 marks) Connectivity in undirected graphs vs. directed graphs. a. (8 marks) Prove that in any connected undirected graph G- (V, E) with VI > 2, there are at least two vertices u, u є V whose removal (along with all the edges that touch them) leaves G still connected. Propose an efficient algorithm to find two such vertices. (Hint: The algorithm should be based on the proof or the proof should be based on the algorithm.) b....
Design And analysis algorithm course . Remarks: In all the algorithms, always explain their correctness and analyze their com- plexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit Question 2: Give an algorithm that finds the maximum size subarray (the entries may not be contiguous) that forms an increasing sequence.
Please explain Remarks: In all algorithm, always prove why they work. ALWAYS, analyze the com- plexity of your algorithms. In all algorithms, always try to get the fastest possible. A correct algorithm with slow running time may not get full credit. In all data structures, try to minimize as much as possible the running time of any operation. . Question 4: 1. Say that we are given a mazimum flow in the network. Then the capacity of one of the...
Remarks: In all the algorithms, always explain their correctness and analyze their complexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit. Say that we are given a rooted tree so that any element in the tree has a profit. An independent set in the tree is a collection of vertices no two of which are a parent and a child. The goal is to find an independent set of...
Say that we have an undirected graph G(V, E) and a pair of vertices s, t and a vertex v that we call a a desired middle vertex . We wish to find out if there exists a simple path (every vertex appears at most once) from s to t that goes via v. Create a flow network by making v a source. Add a new vertex Z as a sink. Join s, t with two directed edges of capacity...
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,......
Design And analysis algorithm course Remarks: In all the algorithms, always explain their correctness and analyze their com- plexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit Question 3: Given a gas station with two pumps, and a collection of cars 1, 2, n with filling time si for item i (on both pumps). Find a schedule that assigns cars to the two pumps, so that if the first...
Graphs (15 points) 14. For the following graph (8 points): a. Find all the edges that are incident of v1: b. Find all the vertices that are adjacent to v3: C. Find all the edges that are adjacent to e1: d. Find all the loops: e. Find all the parallel edges: f. Find all the isolated vertices: g. Find the degree of v3: h. Find the total degree of the graph: e3 e2 V2 VI 26 e4 e7 es 05...
Analyze the worst-case complexity of the algorithm below when using an optimized adjacency list to store G. ComponentCount: Input: G = (V, E): an undirected graph with n vertices and m edges Input: n, m: the order and size of G, respectively Output: the number of connected components in G Pseudocode: comp = n uf = UnionFind(n) For v in V: For u in N(v): If (uf.Find(v) != uf.Find(u)) uf.Union(u, v) comp = comp - 1 End if End for...