heuristic search possible diagonal moves would have the affect of moving through what looks like walls in the maze in some circumstances according to our direction preferencethe algorithm proceeds by making steps and in red then it proceeds to travel to the left into region when it gets to in region athere are no possible moves adjacent to step that have not already been visited the code in lines - cannot find anything to push onto the stack howeverwhen step was originally consideredall the other choices were pushed onto the stack including the red three that appears to the right of step when nothing is pushed onto the stack while looking at step in region athe next top value on the stack is the red step the unvisited nodes adjacent to the red step are then pushed onto the stack the last location pushed is the red step which leads to the red step being pushed and considered next then the depth first search proceeds to the left againexamining all the locations in region when region is exhaustedbacktracking occurs againresulting in taking the red step this leads to the search entering region nextexhausting the possibilities on this path and backtracking occurring to take the search to step in red likewiseregions efand are explored when the search gets to red step the depth first search prefers to go up and proceeds to the top of the maze and enters region we can tell by looking at the maze that entering region will lead nowhere but depth first search does not know or care about this it just blindly considers the next possible path to the goal until that path leads to the goal or we have exhausted all possible next steps and backtrack backtracking out of region leads to step in red when we reach step the algorithm prefers to go down first and proceeds on wild goose chase leading from region to region where it runs out of possible next steps and backtracks to the red step finallythat path leads to the goal there are some things to notice about this search firstas mentioned beforeit was blind search that uses backtracking to eventually find the goal in this example the depth first search examined every location in the mazebut that is not always the case depth first search did find solutionbut it wasn' the optimal solution if the depth first search were programmed to go right first it would have found solution much faster and found the optimal solution for this maze unfortunately of coursethat won' work for all mazes while the maze search space is finitewhat if the maze was infinite in size and we went to the left while we should have started going rightthe algorithm would blindly proceed going left forevernever finding solution the drawbacks of depth first search are as follows depth first search cannot handle infinite search spaces unless it gets lucky and proceeds down path that leads to the goal it does not necessarily find an optimal solution unless we are luckythe search order in finite space may lead to exhaustively trying every possible path we may be able to do better using either breadth first search or heuristic search read on to see how these algorithms work this copy belongs to 'acha