Recursive backtracking
Eight queens puzzle
Javascript (animated)
click on a square on the chessboard to place a queen
This animation shows how a backtracking algorithm works on the eight queens puzzle. The algorithm only takes a few milliseconds, but is shown here at a slower speed to show how it works. The following code shows how to solve this problem with Javascript.
Eight queens puzzle at Wikipedia
Javascript source code:
NOTE: to keep things simple, the animation code is not included in the source