Iterative Depth First Traversal
easy
1. You are given a graph, and a source vertex. 2. You are required to do a iterative depth first traversal and print which vertex is reached via which path, starting from the source. Note -> For output, check the sample output and question video. Iterative depth first traversal should mimic "Reverse preorder" i.e. nbr with highest value should be visited first and should be printed on the way down in recursion.
Constraints
None
Format
Input
Input has been managed for you
Output
Check the sample output
Example
Sample Input
7
8
0 1 10
1 2 10
2 3 10
0 3 10
3 4 10
4 5 10
5 6 10
4 6 10
2
Sample Output
2@2
3@23
4@234
6@2346
5@23465
0@230
1@2301
Question Video