146k views
2 votes
)In a graph represented by adjacency matrix u can find all the neighbours of a given vertices in ____Operations

A. O(1)

B.O(n)

C.O(logn)

D.O(n2)

User Slakter
by
5.3k points

1 Answer

7 votes

Answer:

B.O(n).

Step-by-step explanation:

If the graph is represented by adjacency matrix then we can find all the neighbors of a given vertex in O(n) time because each row in adjacency matrix consists the track of the neighbors.If the other vertex is a neighbor then it contains 1 in adjacency matrix if not it contains 0.So we have to iterate over that row of the vertex to find the neighbors.

User Nikolay Ermakov
by
5.7k points