Finding First Solution

Here is the process of finding our first solution, written in a Pascal-like pseudo-code.

To find a first solution, we ask our neighhbor to find a first solution. If our neighbor cannot find a solution, then there is no hope of our finding a solution, so we can return false.

Otherwise, we try each row in turn, and ask our neighbor if they can attack. If any row works, then we have a solution. Otherwise, if no row works, we ask our neighbor to find another solution, and we try again. When our neighbor reports that no further solutions are possible, we report failure as well.

[audio] [real] Text to accompany slide9, in Chapter 5 of An Introduction to Object-Oriented Programming