Question: in java 7 . 2 3 ( Knight s Tour: Brute - Force Approaches ) In part ( c ) of Exercise 7 . 2
in java
Knights Tour: BruteForce Approaches In part c of Exercise 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 bruteforce problem solving.
Use randomnumber generation to enable the knight to walk around the chessboard in its legitimate Lshaped 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 tours. Use a onedimensional array to keep track of the number of tours of each length. When your application finishes attempting the 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 bruteforce version of the Knights Tour with the accessibilityheuristic 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 accessibilityheuristic approach? Could we be certain in advance of obtaining a full tour with the bruteforce approach? Argue the pros and cons of bruteforce problem solving in general.
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 ie no two queens are in the same row, in the same column or along the same diagonal Use the thinking developed in Exercise 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 as demonstrated by Fig. Once these elimination numbers are placed in all 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.
The squares eliminated by placing a queen in the upper left corner.
Figure Full Alternative Text
Eight Queens: BruteForce Approaches In this exercise, youll develop several bruteforce approaches to solving the Eight Queens problem introduced in Exercise
Use the random bruteforce technique developed in Exercise to solve the Eight Queens problem.
Use an exhaustive technique ie try all possible combinations of eight queens on the chessboard to solve the Eight Queens problem.
Why might the exhaustive bruteforce approach not be appropriate for solving the Knights Tour problem?
Compare and contrast the random bruteforce and exhaustive bruteforce approaches.
Knights Tour: ClosedTour Test In the Knights Tour Exercise a full tour occurs when the knight makes moves, touching each square of the chessboard once and only once. A closed tour occurs when the th move is one move away from the square in which the knight started the tour. Modify the application you wrote in Exercise to test for a closed tour if a full tour has occurred.
Sieve of Eratosthenes A prime number is any integer greater than thats evenly divisible only by itself and The Sieve of Eratosthenes is a method of finding prime numbers. It operates as follows:
Create a primitivetype 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 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 all elements beyond element in the array that have indices which are multiples of indices etc. will be set to false; for array index all elements beyond element in the array that have indices which are multiples of indice
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
