Iterative Depth First Search

When you are aware the solution will be at or near a particular level and you would like the advantages of the small memory requirement of DFS, you just do a normal DFS, but limit it to a certain node depth.

Advantages

Kinda fast, little memory requirement

Disadvantages

You must know that the solution is at a certain level. This depends quite heavily on the problem

Implementation

Quite similar to the DFS implementation in case it has not been done yet.

Java implementation

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License