about summary refs log tree commit diff stats
path: root/algorithms/java/BFS.java
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-11-16 22:43:46 +0530
committerAndinus <andinus@nand.sh>2021-11-16 22:43:46 +0530
commit7858dba48b41417f951031d36e7fbf66da8d14e2 (patch)
tree63d4b0b360181658749cf61224744784250d6938 /algorithms/java/BFS.java
parentd945c6743848890761af2758e7bcec46514746da (diff)
downloadfornax-7858dba48b41417f951031d36e7fbf66da8d14e2.tar.gz
java/DFS: Update to latest fornax format, fix DFS
Now it prints the starting point and all visited path according to the
format.

Earlier we marked paths as unvisited right after we backtrack out of
it. This is not really necessary for us to get the solution because if
we're not able to find a path through that block then we won't find it
with another way of reaching that block either.

Explanation:
AB
X.

If we can't find a path to destination from AX... then we won't find
it form ABX... either. Earlier we were trying ABX... too. I had this
idea in mind because before this I wrote a word search program that
walked in DFS manner, in that case this was required because ABX...
could form a word that AX... couldn't.

The solution was easy, just had to keep it marked as visited and not
revert it. To keep track of current path we created `path'. This is
marked false right after traversal because it keeps track of current
path.
Diffstat (limited to 'algorithms/java/BFS.java')
0 files changed, 0 insertions, 0 deletions