Created
July 24, 2020 08:00
-
-
Save mbchoa/b5c3c3c857274fddd76e72a5a46eaed8 to your computer and use it in GitHub Desktop.
Pseudocode describing general structure of a recursive backtracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bool Solve(configuration conf) { | |
| if (no more choices) { // base case | |
| return (conf is goal state) | |
| } | |
| for (all available choices) { | |
| try one choice C: | |
| // solve here, if it works, you're done | |
| if (Solve(conf with choice C made) return true; | |
| undo choice C | |
| } | |
| return false // tried all choices, no solution found, backtrack | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment