{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

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.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern