The Knight’s tour problem
Algorithm:
- If move == board.size then
- return true
- Iterate all possible 8 positions where Knight can go from current position
- If next position is valid and not visited earlier then
- Set board location = move
- Recursively call with move + 1 and with new position
- If last recursive call was success then
- return true
- else reset location
- return false
Latest Source Code:
Github: TheKnightTourProblem.java
Output:
Path Found!! 0 9 22 63 6 3 12 17 23 62 7 2 11 16 5 14 8 1 10 21 4 13 18 31 61 24 39 42 19 30 15 50 38 43 20 57 40 49 32 29 25 60 41 46 35 28 51 54 44 37 58 27 56 53 48 33 59 26 45 36 47 34 55 52