Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Statistics and Probability Expert

1891_kk.jpg

Figure 2.8. A solution to the eight-queens puzzle. The ``eight-queens puzzle&; asks how to place eight queens on a chessboard so that no queen is in check from any other (i.e., no two queens are in the same row, column, or diagonal). One possible solution is shown in figure 2.8. One way to solve the puzzle is to work across the board, placing a queen in each column. Once we have placed k - 1 queens, we must place the kth queen in a position where it does not check any of the queens already on the board. We can formulate this approach recursively: Assume that we have already generated the sequence of all possible ways to place k - 1 queens in the first k - 1 columns of the board. For each of these ways, generate an extended set of positions by placing a queen in each row of the kth column. Now filter these, keeping only the positions for which the queen in the kth column is safe with respect to the other queens. This produces the sequence of all ways to place k queens in the first k columns. By continuing this process, we will produce not only one solution, but all solutions to the puzzle. We implement this solution as a procedure queens, which returns a sequence of all solutions to the problem of placing n queens on an n× n chessboard. Queens has an internal procedure queen-cols that returns the sequence of all ways to place queens in the first k columns of the board.

1269_kk.jpg

In this procedure rest-of-queens is a way to place k - 1 queens in the first k - 1 columns, and new-row is a proposed row in which to place the queen for the kth column. Complete the program by implementing the representation for sets of board positions, including the procedure adjoinposition, which adjoins a new row-column position to a set of positions, and empty-board, which represents an empty set of positions. You must also write the procedure safe?, which determines for a set of positions, whether the queen in the kth column is safe with respect to the others. (Note that we need only check whether the new queen is safe -- the other queens are already guaranteed safe with respect to each other.) .

Statistics and Probability, Statistics

  • Category:- Statistics and Probability
  • Reference No.:- M91766487

Have any Question?


Related Questions in Statistics and Probability

The number of cell phones per 100 residents in countries in

The number of cell phones per 100 residents in countries in Europe is given in table 9.3.9 for the year 2010. The number of cell phones per 100 residents in countries of the Americas is given in table 9.3.10 also for the ...

The monthly sales demand for a new product is uncertain but

The monthly sales demand for a new product is uncertain, but it is considered to be adequately described by a normal random variable with mean 50,000 units and variance 100,000,000. (a) A factory to manufacture the new p ...

Problem arrival of vehicles at new jersey turnpike toll

Problem: Arrival of vehicles at New Jersey Turnpike toll booth on Saturdays at dawn is modeled as a Poisson Arrival process with a rate of 1.21 vehicles per minute. Let X be a random variable that records the number of a ...

Two fair dice are rolled and the sum of the points is noted

Two fair dice are rolled and the sum of the points is noted. Find the probability that the sum is 6 given that at least one of the numbers is less than 3.

A sample of 100 people is classified by gender malefemale

?A sample of 100 people is classified by gender (male/female) and by whether they are registered voters. The sample consists of 80 females and 20 males, and has a total of 60 registered voters. If these data are used for ...

You are in charge of numbering the homes in a new

You are in charge of numbering the homes in a new subdivision. If we were to ue 0 through 9 as our number to use and we want to have 3 digit house numbers, how many unique homes numbers would we potentially be able to pr ...

Sppose a and b are collectively exhaustive in addition pa

Suppose A and B are collectively exhaustive. In addition, P(A) = 0.2 and P(B) = 0.8. Suppose C and D are both mutually exclusive and collectively exhaustive. Further, P(C|A) = 0.7 and P(D|B) = 0.5. What are P(C) and P(D) ...

For a population of individuals that has a standard

For a population of individuals that has a standard deviation of 10, what is the standard error of the mean for samples of size (a) 2, (b) 3, (c) 4, (d) 5, (e) 10, (f) 20, (g) 100?

1 this table summarizes the results from

1) This table summarizes the results from along+termrandomized clinicaltrial to  determine whether aspirin reduces the risk of heart attack. Researchers  randomly assigned a large sample of healthy male physicians (22,07 ...

The manufacturer of a new fertilizer wants to show that the

The manufacturer of a new fertilizer wants to show that the new chemical increases bean yields. The average acre currently yields 146.8 bushels of beans. State the null and alternative hypotheses that the manufacturer wo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As