The time complexity to calculate the number of edges in a graph whose information in stored in form of an adjacency matrix is ____________

Category: QuestionsThe time complexity to calculate the number of edges in a graph whose information in stored in form of an adjacency matrix is ____________
Editor">Editor Staff asked 4 weeks ago

The time complexity to calculate the number of edges in a graph whose information in stored in form of an adjacency matrix is ____________
 
(a) O(V)
 
(b) O(E^2)
 
(c) O(E)
 
(d) O(V^2)
 
This intriguing question originated from Adjacency Matrix in division Graph of Data Structures & Algorithms I
 
This question was posed to me by my college professor while I was bunking the class.

1 Answers
Editor">Editor Staff answered 4 weeks ago

The correct option is (d) O(V^2)
 
Explanation: As V entries are 0, a total of V^2-V entries are to be examined.