Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The problem Write a program that inputs two integers n and k, where n>=k. Your program should calculate the number of different ways that k

image text in transcribed

The problem

Write a program that inputs two integers n and k, where n>=k. Your program should calculate the number of different ways that k bishops could be placed on an nXn chessboard. Structure your program using the backtracking scheme that we have used for the eight queens problem. What needs to be modified is the OK function.

Input

Your main program should loop asking the user for values of n and k.

Output

Each time through the loop, output n, k and the number of configurations. Program Termination The program will terminate if the user enters a value of -1 for n.

k bishops on an nXn chessboard We have previously solved the "N Queens Problem", where, for a given n, we calculated the number of ways to place n queens on an nXn board. This problem concerns "bishops" on the chessboard. What is a bishop? A bishop is a chess piece that controls all the squares on the two diagonals that it can reach Note that a bishop may be either on a white square or a black square. The problenm Write a program that inputs two integers n and k, where n>-k. Your program should calculate the number of different ways that k bishops could be placed on an nXn chessboard Structure your program using the backtracking scheme that we have used for the eight queens problem. What needs to be modified is the "OK" function Input Your main program should loop asking the user for values of n and k. Output Each time through the loop, output n, k and the number of configurations. Program Termination The program will terminate if the user enters a value of-1 for n

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books