198k views
1 vote
)In the ADT graph, the method getNumberOfEdges has efficiency

A. O(1)

B.O(n)

C.O(logn)

D.O(n2)

User Criddell
by
8.2k points

1 Answer

5 votes

Answer:

B.O(n)

Step-by-step explanation:

In ADT graph the efficiency of the method getNumberOfEdges is O(n) because to get the number of edges we have to traverse the whole graph or every vertex if there are n vertices so the time complexity of traversing the graph comes out to be O(n).

Hence we conclude that the answer to this question is O(n).

User Crodica
by
8.2k points

Related questions

1 answer
3 votes
114k views
1 answer
2 votes
55.8k views
2 answers
2 votes
227k views