day10 - COP 3503 Computer Science II CLASS NOTES - DAY #10...

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

View Full Document Right Arrow Icon
COP 3503 – Computer Science II CLASS NOTES - DAY #10 Backtracking Algorithms Backtracking algorithms use recursion to try all possible solutions and pick the optimal solution from the set of all solutions. This is a common strategy employed in AI games, parsers, etc. Since trying all possible solutions is essentially an exhaustive searching technique there must be a technique which will allow a backtracking algorithm to “know” that some solution paths are not optimal and therefore need not be explored. This technique is known as search tree pruning and we will examine it later. Many problems can be viewed in terms of abstract graphs. For example, the nodes in a graph can represent the positions in a chess game and the edges represent the legal moves. Often the original problem translates to searching for a specific node, path, or pattern in the associated graph. If the graph contains a large number of nodes, and particularly if it is infinite, it may be wasteful or infeasible to explicitly build it in memory before applying a search technique to the graph. In such cases an implicit graph is required. An implicit graph (recall that a tree is just a special case of a graph) is one for which a description of its nodes and edges is available, so that only the relevant parts of the graph are constructed as the search progresses. Computing time is reduced whenever the search succeeds before the entire graph has been constructed. A savings in terms of memory is also achieved with implict graphs and can be further enhanced whenever nodes that have been previously searched can be discarded thereby making room for nodes to be subsequently explored (this is not always possible however). If the graph is infinite, then the implicit graph technique offers the only hope of exploring all of the graph. In its basic form, backtracking resembles a depth-first search in a digraph (directed graph). The digraph concerned is typically a tree (or at least it contains no cycles). The digraph is assumed to be implicit regardless of its structure. The aim of the search is to find solutions to the problem represented by the digraph. This is done by building partial solutions as the search proceeds; such partial solutions limit the regions in which a complete solution may be found. Generally speaking, when a search begins, nothing is known about the solutions to the problem. Each move along an edge of the implicit graph corresponds to adding a new element to a partial solution, i.e., it narrows down the remaining possibilities for a complete solution. The search is successful if, proceeding in this way, a solution can be completely defined. In this case the algorithm may stop (if there only one solution to the problem is required) or continue looking for alternative solutions (if you would like to see all of the solutions). On the other hand, the search is unsuccessful if at some stage the partial solution constructed so far cannot be completed.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/22/2009 for the course COP 3503c taught by Professor Staff during the Spring '08 term at University of Central Florida.

Page1 / 11

day10 - COP 3503 Computer Science II CLASS NOTES - DAY #10...

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

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