SYSC 2100 Lecture Notes - Lecture 8: Algebraic Expression, Empty String

88 views2 pages

Document Summary

Backtracking is a solution strategy that involves both recursion and a sequence of guesses that ultimately lead to a solution. If a guess leads to an impasse, retrace the steps in reverse order, replace that guess with a new one, and try to complete the solution. A recursive algorithm that places a queen in a column. Base case: no more columns to consider nished. If a queen is successfully placed in a current column consider next column. If a queen cannot be placed in current column backtrack placequeens (in currcolumn : integer) // places queens in columns numbered currcolumn through 8. if (currcolumn > 8) the problem is solved else { while (unconsidered squares exist in currcolumn and the problem is unsolved) { Determine the next square in column currcolumn that is not under attack by a queen in an earlier column if (such a square exists) {

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents