+1 vote
by
There is a two-dimensional array and a finite number of cells next to the same data value.
You have to go around them
by
Alexander Lol. That's what you came here for.
by
I don't understand the rule for bypassing a two-dimensional array. What prevents you from simply traversing it in both dimensions?
by
Denis Zagaevsky , Learn not to lecture strangers about life
by
Alexander I didn't get any clearer. Learn how to formulate a thought.
by
Karpion You can say that you have to go through the cells with the same value, that is, they are connected. If they are next to each other.
by
Alexander any of graph traversal algorithms that work with the notion "for each vertex there is a list of vertices connected to it" is good enough for you. How to make this list - you said yourself.

2 Answers

0 votes
by
If the recursion fails, do a width bypass (with a queue) instead of a depth bypass.
by
Alexander , In depth always uses the stack. You can implement it yourself instead of using the system one to do recursion. Roughly speaking, take wikipedia's implementation of traversal in width and use stack instead of queue.
by
Doesn't the depth also come with a stack?
0 votes
by
Make an "index" (as in books).
...