+1 vote
in Data Structures & Algorithms I by (88.2k points)
Time complexity to check if an edge exists between two vertices would be ___________

(a) O(V*V)

(b) O(V+E)

(c) O(1)

(d) O(E)

My doubt is from Incidence Matrix and Graph Structured Stack topic in portion Graph of Data Structures & Algorithms I

This question was posed to me during an online interview.

1 Answer

+1 vote
by (737k points)
selected by
Best answer
The correct answer is (d) O(E)

Best explanation: We have to check for all edges, in the worst case the vertices will have no common edge.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.