I wrote the below code and tested with n =2 and n=3.

The idea is given a position (i,j) queen has three possibilities (i,j
+1),(i+1,,j+1) (i+1,,j) (Off Course not always since bounds needs to
be checked)

int numOfPath = 0;
int n = 3;
void FollowPath(int i,int j)
{
    if (i >= n || j >=n)
    {
       if ( i == n && j == n)
           ++numOfPath;
        return;
     }

     FollowPath(i,,j+1);
     FollowPath(i+1,j+1);
     FollowPath(i,j+1);
}

main()
{
   FollowPath(0,0);
   cout<<numOfPath<<endl;
}

For n=2 it give 3 and for n=3 it gave 13(which is correct)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to