Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Backtracking
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Pseudocode=== In order to apply backtracking to a specific class of problems, one must provide the data ''P'' for the particular instance of the problem that is to be solved, and six [[procedural parameter]]s, ''root'', ''reject'', ''accept'', ''first'', ''next'', and ''output''. These procedures should take the instance data ''P'' as a parameter and should do the following: # ''root''(''P''): return the partial candidate at the root of the search tree. # ''reject''(''P'',''c''): return ''true'' only if the partial candidate ''c'' is not worth completing. # ''accept''(''P'',''c''): return ''true'' if ''c'' is a solution of ''P'', and ''false'' otherwise. # ''first''(''P'',''c''): generate the first extension of candidate ''c''. # ''next''(''P'',''s''): generate the next alternative extension of a candidate, after the extension ''s''. # ''output''(''P'',''c''): use the solution ''c'' of ''P'', as appropriate to the application. The backtracking algorithm reduces the problem to the call ''backtrack''(''P'', ''root''(''P'')), where ''backtrack'' is the following recursive procedure: '''procedure''' backtrack(P, c) '''is''' '''if''' reject(P, c) '''then''' return '''if''' accept(P, c) '''then''' output(P, c) s β first(P, c) '''while''' s β NULL '''do''' backtrack(P, s) s β next(P, s)
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)