How to implement DFS without recursion and if there are many circular connections?
There is a two-dimensional array and a finite number of cells next to the same data value.
Compile an "index" (like in books).Anonymous
If the recursion fails, then do not depth-first traversal, but breadth-first traversal (with a queue).Anonymous
To place the code, please use CodePen or similar tool. Thanks you!