Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

11. | 14 points! Let G = (V,E) be a directed graph. The in-degree of a vertex u

ID: 3712635 • Letter: 1

Question

11. | 14 points! Let G = (V,E) be a directed graph. The in-degree of a vertex u is the number of edges (a) Design an algorithm (give pseudocode) that, given a vertex u ? V, com putes the in-degree of u under (b) Design an algorithm (give pseudocode) that, given a vertex u ? V, computes the in-degree of u 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 represented by an adjacency matrix. Give an analysis of your

Explanation / Answer

Solution:

a)

Algorithm(Pseudocode):

Running time:

The above algorithm tracing the number of vertices which is present in each list and the maximum number of vertices which will be visited can be n(n-1), so the complexity will be O(n^2).

b)

Algorithm(Pseudocode):

Running time: This algorithm will simply take O(n) time in execution.

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)