educative.io

Inconsistent output

The DFS output in the solution is different from the DFS output on the previous page.


Course: https://www.educative.io/collection/5642554087309312/5724822843686912
Lesson: https://www.educative.io/collection/page/5642554087309312/5724822843686912/6208139315642368

Hello @Kevin1,

I would like to clarify that both outputs are correct. The sample output shown in the Challenge lesson may differ from the output provided in the Solution lesson because the Challenge lesson’s output is expected when the Depth-First Search (DFS) algorithm is applied from right to left, while the Solution lesson’s output is obtained when the graph is traversed from left to right. Both approaches are valid in the context of graph.

However, we understand that this may have caused some confusion, and as a result, we have updated the Challenge lesson to include all the valid outputs. We hope this clarifies any doubts you may have had. If you have any further questions, please feel free to ask.
Thank you for bringing this to our attention. :raised_hands:

1 Like