Skip to content
GATEiit

GATE CSE 2018 Q40: Cross edges in DFS tree and level differences in BFS tree

Syllabus topic: Graph traversals, minimum spanning trees and shortest paths

Question

Let G be a simple undirected graph. Let TD be a depth first search tree of G. Let TB be a breadth first search tree of G. Consider the following statements.

(I) No edge of G is a cross edge with respect to TD. (A cross edge in G is between two nodes neither of which is an ancestor of the other in TD.)

(II) For every edge (u,v) of G, if u is at depth i and v is at depth j in TB, then ∣i−j∣=1.

Which of the statements above must necessarily be true?

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: A (official GATE 2018 final answer key)

Concept used: In an undirected graph, DFS produces only tree and back edges; BFS guarantees the depths of the endpoints of any edge differ by at most 1 (possibly 0).

Concept notes

Loading notes…

First step: For statement II, try a triangle: run BFS from one vertex and look at the depths of the two other vertices, which are joined by an edge.

Full step-by-step solution

Loading…

Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.

More questions on Graph traversals, minimum spanning trees and shortest paths

Every PYQ on this topic →

Share this question

WhatsAppDownload image

Source: official GATE 2018 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key