Hi folks
I'm trying to develop a breadth first search method but having some problems. I'm trying to add a string (MI) as the lone member of a queue, and expand on that string using my nextStates( that string ) method if it doesnt match a pre-determined string (b) defined in the main. Below is my code, so far it doesn't return anything even though b is a next state of MI. Was wondering if anyone could point out why this is and a possible fix. Any help would be appreciated. Thanks
Code:public static boolean breadthFirstSearch (String b)
{
boolean flag = false;
Queue<String> qe=new LinkedList<String>(); //sets up queue
qe.add("MI"); //adds MI to queue
while(flag = false)
{
qe.addAll(nextStates(qe.element())); //add all the nextStates of b to the queue
if(qe.poll()== b)
{
flag = true;
System.out.println("found!"); //found the state therefore
}
}
return true;
}

