Skip to content
Advertisement

Tag: tree-search

Is it possible to do a depth first search iteratively without copying visited nodes?

Background I am searching a 2D grid for a word. We can search left/right and up/down. For example, in this grid, searching for “abef” starting at (0,0) will return True Example (grid1): Where I’m at The recursive version gives expected results (see dfs_rec() below). The iterative version also gives expected results (see dfs_iter() below). However, in this version I am

Advertisement