Vidyalelo
Data Structure · Q149

Graphs

Programming · Data Structure · question 149

Q149

What would be the time complexity of the following function which adds an edge between two vertices i and j, with some weight 'weigh' to the graph having V vertices? vector adjacent[15] ; vector weight[15]; void addEdge(int i,int j,int weigh) adjacent[a].push_back(i); adjacent[b].push_back(j); weight[a].push_back(weigh); weight[b].push_back(weigh);

A.
O(1)
Answer
B.
O(V)
C.
O(V*V)
D.
O(log V)

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board