educative.io

Educative

Wrong Answer mentioned

Shouldn’t the (5,3) edge be (3,5) to include 5 in the graph’s dfs?


Course: Algorithms for Coding Interviews in Java - Learn Interactively
Lesson: Solution Review: Print all the Connected Components of a Graph - Algorithms for Coding Interviews in Java

Hi @Prakhar_Shukla,

It does not matter if we write it as (5,3) or (3,5) because it is an undirected graph and includes 5 in both cases.

I hope this helps!