Shortcut for chapter specific information

Showing posts with label recursive backtracking. Show all posts
Showing posts with label recursive backtracking. Show all posts

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.

Thursday, September 1, 2011

Recursive-Backtracking

Take a look of the lecture notes.  It doesn't seem to be too difficult.  But oh well, I am done for today.  Let's go to sleep first and work on the rest of the problems.