...
Question 8113 – Data-Structures
April 17, 2024
Question 8516 – Data-Structures
April 17, 2024
Question 8113 – Data-Structures
April 17, 2024
Question 8516 – Data-Structures
April 17, 2024

GATE 2014 [Set-1]

Question 21

Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time of Depth First Search on G, when G is represented as an adjacency matrix?

A
θ(n)
B
θ(n+m)
C
θ(n2)
D
θ(m2)
Question 21 Explanation: 
DFS visits each vertex once and as it visits each vertex, we need to find all of its neighbours to figure out where to search next. Finding all its neighbours in an adjacency matrix requires O(V ) time, so overall the running time will be O(V2).
Correct Answer: C
Question 21 Explanation: 
DFS visits each vertex once and as it visits each vertex, we need to find all of its neighbours to figure out where to search next. Finding all its neighbours in an adjacency matrix requires O(V ) time, so overall the running time will be O(V2).

Leave a Reply

Your email address will not be published. Required fields are marked *