Question: in java 7 . 2 3 ( Knight s Tour: Brute - Force Approaches ) In part ( c ) of Exercise 7 . 2

in java
7.23(Knights Tour: Brute-Force Approaches) In part (c) of Exercise 7.22, we developed a solution to the Knights Tour problem. The approach used, called the accessibility heuristic, generates many solutions and executes efficiently.
As computers continue to increase in power, well be able to solve more problems with sheer computer power and relatively unsophisticated algorithms. Lets call this approach brute-force problem solving.
Use random-number generation to enable the knight to walk around the chessboard (in its legitimate L-shaped moves) at random. Your application should run one tour and display the final chessboard. How far did the knight get?
Most likely, the application in part (a) produced a relatively short tour. Now modify your application to attempt 1,000 tours. Use a one-dimensional array to keep track of the number of tours of each length. When your application finishes attempting the 1,000 tours, it should display this information in neat tabular format. What was the best result?
Most likely, the application in part (b) gave you some respectable tours, but no full tours. Now let your application run until it produces a full tour. [Caution: This version of the application could run for hours on a powerful computer.] Once again, keep a table of the number of tours of each length, and display this table when the first full tour is found. How many tours did your application attempt before producing a full tour? How much time did it take?
Compare the brute-force version of the Knights Tour with the accessibility-heuristic version. Which required a more careful study of the problem? Which algorithm was more difficult to develop? Which required more computer power? Could we be certain (in advance) of obtaining a full tour with the accessibility-heuristic approach? Could we be certain (in advance) of obtaining a full tour with the brute-force approach? Argue the pros and cons of brute-force problem solving in general.
7.24(Eight Queens) Another puzzler for chess buffs is the Eight Queens problem, which asks the following: Is it possible to place eight queens on an empty chessboard so that no queen is attacking any other (i.e., no two queens are in the same row, in the same column or along the same diagonal)? Use the thinking developed in Exercise 7.22 to formulate a heuristic for solving the Eight Queens problem. Run your application. [Hint: Its possible to assign a value to each square of the chessboard to indicate how many squares of an empty chessboard are eliminated if a queen is placed in that square. Each of the corners would be assigned the value 22, as demonstrated by Fig. 7.31. Once these elimination numbers are placed in all 64 squares, an appropriate heuristic might be as follows: Place the next queen in the square with the smallest elimination number. Why is this strategy intuitively appealing?]
Fig. 7.31
The 22 squares eliminated by placing a queen in the upper left corner.
Figure 7.31 Full Alternative Text
7.25(Eight Queens: Brute-Force Approaches) In this exercise, youll develop several brute-force approaches to solving the Eight Queens problem introduced in Exercise 7.24.
Use the random brute-force technique developed in Exercise 7.23 to solve the Eight Queens problem.
Use an exhaustive technique (i.e., try all possible combinations of eight queens on the chessboard) to solve the Eight Queens problem.
Why might the exhaustive brute-force approach not be appropriate for solving the Knights Tour problem?
Compare and contrast the random brute-force and exhaustive brute-force approaches.
7.26(Knights Tour: Closed-Tour Test) In the Knights Tour (Exercise 7.22), a full tour occurs when the knight makes 64 moves, touching each square of the chessboard once and only once. A closed tour occurs when the 64th move is one move away from the square in which the knight started the tour. Modify the application you wrote in Exercise 7.22 to test for a closed tour if a full tour has occurred.
7.27(Sieve of Eratosthenes) A prime number is any integer greater than 1 thats evenly divisible only by itself and 1. The Sieve of Eratosthenes is a method of finding prime numbers. It operates as follows:
Create a primitive-type boolean array with all elements initialized to true. Array elements with prime indices will remain true. All other array elements will eventually be set to false.
Starting with array index 2, determine whether a given element is true. If so, loop through the remainder of the array and set to false every element whose index is a multiple of the index for the element with value true. Then continue the process with the next element with value true. For array index 2, all elements beyond element 2 in the array that have indices which are multiples of 2(indices 4,6,8,10, etc.) will be set to false; for array index 3, all elements beyond element 3 in the array that have indices which are multiples of 3(indice

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!