Computer Sciences > Gate 2014 Set-1 > Graph Theory
Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time on Depth First Search of G?
Assume that the graph is represented using adjacency matrix.
A
θ (n)
B
θ (n+m)
C
θ(n2)
D
θ(m2)

Correct : Graph Theory

The question asks for the tightest upper bound for Depth First Search (DFS) when the graph is represented using an adjacency matrix.
Analyze the Options:
A) θ(n): DFS visits all n vertices, but with an adjacency matrix, we must check all possible vertices in each row. Therefore, θ(n) is not sufficient.
B) θ(n + m): This is the typical DFS complexity when an adjacency list is used. It is not the complexity for an adjacency matrix.
C) θ(n2): In an adjacency matrix, each vertex has a row containing n entries. DFS may need to examine all n entries for each of the n vertices. Therefore, the total running time is θ(n × n) = θ(n2).
Example: If a graph has 5 vertices, the adjacency matrix has 5 × 5 = 25 entries. DFS may need to check all 25 entries to determine which vertices are connected.
D) θ(m2): The running time of DFS with an adjacency matrix depends on the number of vertices, not the square of the number of edges.
Correct Answer: C) θ(n2)

Similar Questions

Let G=(V,E) be a directed graph where V is the set of vertices and E the set of edges. Then which one of the following graphs has the same strongly connected co...
#18 MCQ
In an adjacency list representation of an undirected simple graph G = (V, E), each edge (u, v) has two adjacency list entries: [v] in the adjacency list of u, a...
#91 MCQ
Consider a set U of 23 different compounds in a Chemistry lab. There is a subset S of U of 9 compounds, each of which reacts with exactly 3 compounds of U. Cons...
#95 MCQ

Related Topics

Depth First Search DFS running time adjacency matrix graph algorithms time complexity GATE Computer Sciences 2014 GATE CS 2014 Set-1 Q2 graph traversal complexity

Unique Visitor Count

Total Unique Visitors

Loading......