CS112_12_slides-gametrees - Recursive Backtrackingcont...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS112 Fundamentals of Programming Abstractions Recursive Backtracking- cont. Yinglin Wang CS Dept., SJTU 2 CS112 Fundamentals of Programming Abstractions Backtracking § Many problems can be thought of as a search through a space consisting of various nodes. § Each node represents a state of the world. § what we are trying to do is find a path from the starting node to a node that represents success.
Image of page 1

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

View Full Document Right Arrow Icon
3 CS112 Fundamentals of Programming Abstractions backtracking Start Success! Success! Failure Key Points: If a node only leads to failure go back to its "parent“node. Try other alternatives. If these all lead to failure then more backtracking may be necessary. 4 CS112 Fundamentals of Programming Abstractions backtracking Backtracking: When you make a sequence of decision choices as you search a goal through a state space., if you reach a dead-end or other-wise discover that you have made a incorrect choice somewhere along the way, you have to return to a previous decision point and try a different path. This kind of methods is called backtracking. The basic strategy is to write programs that can backtracking to previous decision points if those choices lead to dead-end; You can use recursion to implement backtracking search .
Image of page 2