Skip to content
Advertisement

Tag: depth-first-search

Knights tour – results in an infinite loop and i can’t figure out why

I’m trying to solve the knight’s tour problem using backtracking. I think the algorithm I have should work. I’ve tried but I can’t figure out why it isn’t working. It results in an infinite loop. However if I comment out the line that back track solutionBoard[dst.x][dst.y]=-1; it works! I just don’t understand why! Any help would be appreciated. Answer Your

Knight’s tour depth-first search infinite loop

I’m trying to solve the knight’s tour problem using a depth-first search algorithm. The algorithm seems te be looping whenever it has two choices that both result in a dead end. I understand that this is caused because the algorithm resets the ‘wasVisited’ boolean to false again whenever a dead end is found but i simply don’t know how to

Advertisement