Is it possible to solve the maze problem using Depth first search implemented using a stack.
I think it's impossible. because with the stack implementation you cannot backtrack.
If you use the recursive implementation of Depth first search you can backtrack.
Any idea's ?
You can't backtrack using a stack? How do you think recursion works?
thanks neoblack. Now in the recursive implementation of depth first search how do i print only the successfull path through the maze?
NeonBlack is correct. Whatever can be done through recursion can always be done through maintaining an explicit stack.
However, it is always much clearer to just use recursion.
If you maintain an explicit stack then the successful path should exactly match the contents of the stack at the point you find the exit.
Oh okay i'll try my best to solve this.
Of course it's possible. But solving a maze through breadth first search is a LOT better in my opinion.