Solved After Generating The Dfs Tree Using Stack Method

Solved After Generating The Dfs Tree Using Stack Method