Answer to Question #17503 in Quantitative Methods for Sujata Roy
To detect a collision between Queens, we need to check the columns and the diagonals. Collisions can be easily checked if we assign index positions to chess board matrix and keep 3 separate collision lists: one for columns and two for the diagonals. We update the collision lists whenever a Queen is placed. For the column list, we simply add the Queen’s column position; for one diagonal, we add the sum of the Queen’s line with the Queen’s column to the list; and for the other diagonal, we add the subtraction of the line and column position to the list.
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!