Algorithm 1 eightQueens(partialSolution)
1: // Prints all solutions to the 8-Queens problem.
2: input: current partialsolution
3: output: prints all possible solutions to the 8-queens problem.
4: if (length(partialSolution) = 8) then
5: print partialSolution
6: else
7: possibleItems ← getPossibleNextPositions(partialSolution)
8: k ← 0
9: while (k < length(possibleItems)) do
10: add(possibleItems[k], partialSolution)
11: eightQueens(partialSolution)
12: delete(length(partialSolution)-1, partialSolution)
13: k ← k + 1
14: end while
15: end if
Write down the module getPossibleNextPositions for the n Queens problem?
- Posted:
- 3+ months ago by g007ak47
- Topics:
- write, print, solution, current, problem, computer science
Details:
Answers
No answers have yet been posted. Add your answer to this question.