Question: Question 2. (1 marks) We say that a node u of a directed graph G (V, E) is a supersource, if there is an edge

Question 2. (1 marks) We say that a node u of a directed graph G (V, E) is a supersource, if there is an edge from u to every other node in G and there is no edge from any node into u, i.e., for all uu E V, (u,v) E E and for all u e V, (v,u) E. a. Suppose the directed graph G (V, E) is given by its adjacency matriz A. Give an efficient algorithm to determine whether G has a supersource node, and if so, to output it. Your algorithm should minimize the number of accesses to the adjacency matrix A in the worst-case (e.g., reading an arbitrary element Ali,j of A counts as one access to A). Describe your algorithm using pseudo-code and prove it correct (it is convenient to assume that the set of nodes of G is V 1,2,..,n)). b. How many times your algorithm accesses the adjacency matrix A of the graph G in the worst-case? Give the eract number (i.e., do not use the asymptotic notation) as a function of the number of nodes n = IVI and the number of edges rn = El of G, and justify your answer c. Solve part (a) and (b) above under the assumption that the directed graph G = (V, E) is given by its adjacency lists L (instead of its adjacency matrix A). Question 2. (1 marks) We say that a node u of a directed graph G (V, E) is a supersource, if there is an edge from u to every other node in G and there is no edge from any node into u, i.e., for all uu E V, (u,v) E E and for all u e V, (v,u) E. a. Suppose the directed graph G (V, E) is given by its adjacency matriz A. Give an efficient algorithm to determine whether G has a supersource node, and if so, to output it. Your algorithm should minimize the number of accesses to the adjacency matrix A in the worst-case (e.g., reading an arbitrary element Ali,j of A counts as one access to A). Describe your algorithm using pseudo-code and prove it correct (it is convenient to assume that the set of nodes of G is V 1,2,..,n)). b. How many times your algorithm accesses the adjacency matrix A of the graph G in the worst-case? Give the eract number (i.e., do not use the asymptotic notation) as a function of the number of nodes n = IVI and the number of edges rn = El of G, and justify your answer c. Solve part (a) and (b) above under the assumption that the directed graph G = (V, E) is given by its adjacency lists L (instead of its adjacency matrix A)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
