Category "breadth-first-search"

Why "for i in q" makes the result different from "for i in range(len(q))"?

I have code for calculating max depth using BFS, which works fine, but I couldn't figure out why it fails if I replaced for i in range(len(q)): with for i in q:

My implementation of Breadth First Search with forEach doesn't work

Here is my code inside a BinarySearchTree class. I don't know if it is because of the behaviour of forEach, or because somewhere in my code is wrong. class Bina

How to detect cycle using itarative approach

I am trying to learn how to detect cycle. I see many example of using recursion but I want to implement in iterative way. Here is my code public boolean cycleDe

Breadth-first traversal of a tree of slider puzzle configurations java

I need help with my PuzzleSolver class. I get a notice saying Note: SliderPuzzleSolver.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:u

Finding the shortest path to solve colored water sorting games

So my aunt plays this now popular mobile game, shown in the picture below. She got stuck on a certain level and asked me if I can solve it. Knowing that I'm not