SUNY Geneseo Department of Computer Science


Backtracking and the n Queens Problem

Thursday, May 2

CSci 242, Spring 2013
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture

Misc

My hash table solution is available via our “Exercises” page

Final

Questions?

Backtracking

Example: the n queens problem

4 queens on a 4-by-4 board such that none can attack another

Design an algorithm to solve n queens

            backtrack( … partialSolution … )
                …
                backtrack( … partialSolution + next part … )

Algorithm to solve n queens

Next

Randomized algorithms


Next Lecture