Shortcut for chapter specific information

Friday, September 2, 2011

Recursive Backtracking Revisited

After going through the notes on recursive backtracking, I have a much better idea on how to solve the third homework problem.  As it turns out it is not a super hard problem.

There is a template of backtracking and it looks like this in this not so right CLRS pseudo

FindSolution(X):
    if X is valid solution:
          return true
   else
          return false
   for value you want to scan
         if the solution is valid
              putValue on the state space.
              if(FindSolution (f(X))
                     return true
              removeValue from the state space.
   return false

The lecture note use an example from N-queen to discuss this problem which is fairly interesting.  I was quickly able to adapt the template to make my solution.

Let's implement and see if it works.

No comments:

Post a Comment