A matrix of 150×150 size will describe our labyrinth, so for example if the matrix were only 10×10 we would have something like this:
1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 1 0 0<-F
1 0 1 1 0 1 0 1 0 1
1 1 1 1 0 1 0 0 0 1
1 1 1 1 0 1 1 1 1 1
1 0 0 0 0 1 1 1 1 1
1 0 1 1 0 1 1 1 1 1
1 0 1 0 0 0 0 1 1 1
S->0 0 1 1 1 1 0 1 1 1
1 1 1 1 1 1 1 1 1 1
Where S marks the starting point and F the exit of the labyrinth.
The purpose of this program is to generate a Binary Tree that will describe all the paths we traveled while trying to find the exit.
How would you acomplish that? I’m really lost this time, I don’t really know where to start that’s why I’m not posting anything I’ve tried but if you could please give me a direction I would be really really grateful.
John Smith.
you might want to try backtracking
here’s a complete example of how to solve this problem… however: it can’t operate on a maze with “islands” in it as it would be necessary to aditionally track where you have been already. but i think you can figure out how to do this as well…
the output should be:
right, up, up, up, right, right, right, up, up, up, up, right, right, down, down, right, right, up, up, right, finish!