Consider an unweighted, undirected graph G = . Theneighbourhood of a node v ? V in the graph is the set of all nodesthat are adjacent (or directly connected) to v. Subsequently, wecan define the neighbourhood degree of the node v as the sum of thedegrees of all its neighbours (those nodes that are directlyconnects to v).
(a) Design an algorithm that returns a list containing theneighbourhood degree for each node v ? V, assuming that the inputis the graph, G, represented using an adjacency list. Each item iin the list that you generate will correspond to the correct valuefor the neighbourhood degree of node vi. Your algorithm should bepresented in unambiguous pseudocode. Your algorithm should have atime complexity value O(V +E).
(b) If an adjacency matrix was used to represent the graphinstead of an adjacency list, what is the new value for the timecomplexity? Justify your answer by explicitly referring to thechanges that would be necessary to your algorithm from part(a).