Open In App

GATE | GATE-CS-2014-(Set-3) | Question 23

Like Article
Like
Save
Share
Report

Suppose depth first search is executed on the graph below starting at some unknown vertex. Assume that a recursive call to visit a vertex is made only after first checking that the vertex has not been visited earlier. Then the maximum possible recursion depth (including the initial call) is _________.

GATECS2014Q20
(A) 17
(B) 18
(C) 19
(D) 20


Answer: (C)

Explanation: The following diagram shows the worst case situation where the recursion tree has maximum depth.

GATECS2014Q20Sol

So the recursion depth is 19 (including the first node).

Quiz of this Question


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads