solu12 - This file contains the exercises, hints, and...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
This fle contains the exercises, hints, and solutions For Chapter 12 oF the book ”Introduction to the Design and Analysis oF Algorithms,” 2nd edition, by A. Levitin. The problems that might be challenging For at least some students are marked by ± ; those that might be difficult For a majority oF students are marked by ² . Exercises 12.1 1. a. Continue the backtracking search For a solution to the Four-queens problem, which was started in this section, to fnd the second solution to the problem. b. Explain how the board’s symmetry can be used to fnd the second solution to the Four-queens problem. 2. a. Which is the last solution to the fve-queens problem Found by the backtracking algorithm? b. Use the board’s symmetry to fnd at least Four other solutions to the problem. 3. a. Implement the backtracking algorithm For the n -queensprob leminthe language oF your choice. Run your program For a sample oF n values to get the numbers oF nodes in the algorithm’s state-space trees. Compare these numbers with the numbers oF candidate solutions generated by the exhaustive-search algorithm For this problem. b. ±or each value oF n For which you run your program in part a, estimate the size oF the state-space tree by the method described in Section 12.1 and compare the estimate with the actual number oF nodes you obtained. 4. Apply backtracking to the problem oF fnding a Hamiltonian circuit in the Following graph. f a b g d e c 5. Apply backtracking to solve the 3-coloring problem For the graph in ±igure 12.3a. 6. Generate all permutations oF { 1 , 2 , 3 , 4 } by backtracking. 7. a. Apply backtracking to solve the Following instance oF the subset-sum problem: S = { 1 , 3 , 4 , 5 } and d =11 . b. Will the backtracking algorithm work correctly iF we use just one oF the two inequalities to terminate a node as nonpromising? 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8. The general template for backtracking algorithms, which was given in Section 12.1, works correctly only if no solution is a preFx to another solution to the problem. Change the pseudocode to work correctly for such problems as well. 9. Write a program implementing a backtracking algorithm for a. the Hamiltonian circuit problem. b. the m -coloring problem. 10. Puzzle pegs This puzzle-like game is played on a board with 15 small holes arranged in an equilateral triangle. In an initial position, all but one of the holes are occupied by pegs, as in the example shown below. A legal move is a jump of a peg over its immediate neighbor into an empty square opposite; the jump removes the jumped-over neighbor from the board. Design and implement a backtracking algorithm for solving the following versions of this puzzle. a. Starting with a given location of the empty hole, Fnd a shortest se- quence of moves that eliminates 14 pegs with no limitations on the Fnal position of the remaining peg.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/28/2010 for the course CS CSE taught by Professor Drt during the Spring '10 term at Kaplan University.

Page1 / 35

solu12 - This file contains the exercises, hints, and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online