18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Backtracking<br />

report it.<br />

kth elements of solution A.<br />

if is a solution,<br />

k = k + 1<br />

k = k - 1 (*backtrack*)<br />

compute , the set of candidate<br />

Backtracking constructs a tree of partial solutions, where each vertex is a partial solution. <strong>The</strong>re is an edge from x to y if<br />

node y was created by advancing from x. This tree of partial solutions provides an alternative way to think about<br />

backtracking, for the process of constructing the solutions corresponds exactly to doing a depth-first traversal of the<br />

backtrack tree. Viewing backtracking as depth-first search yields a natural recursive implementation of the basic algorithm:<br />

Backtrack-DFS(A,k)<br />

if is a solution, report it.<br />

else<br />

k = k +1<br />

compute<br />

file:///E|/BOOK/BOOK2/NODE84.HTM (2 of 3) [19/1/2003 1:29:24]<br />

while do<br />

= an element in<br />

=

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!