No, it's definitely not going the right way......
 
i wonder if this can be done using that formula.......
 
here's this algo i just thought.....
 
Suppose u've got m horizontal lines and  n vertical and u give each of them an index value. i.e. a 3x2 grid would be like...
 ___!_(1)_________! (2)_______
 ___!_(3)_________! (4)_______
 ___!_(5)_________! (6)_______
      !                     !
 
we start from node x to node y and the nodes we have traversed are stored in an array named TRAVERSED..the fnxn uses recursion and the algo can be said as a backtracking algo since it checks all the nodes in a particular path if already travelled it returns from that very node
 
 
ways = 0 ;     // initially
 
Start( x,y, TRAVERSED)
{
 
      if(x is an element of TRAVERSED)  // can be found using a loop
             return;
 
     store x in TRAVERSED
     if(x==y)
      {
           
            ways++;    // ways is the variable that counts the valid path found
            return;
     }
    
     if (x-1>=0)     // moving left from current node
         start(x-1,y,TRAVERSED);
     if (x+1>=m*n)     // moving right from current node
         start(x+1,y,TRAVERSED);
     if (x-n>=0)     // moving up from current node
         start(x-n,y,TRAVERSED);
     if (x+n>=0)     // moving down from current node
         start(x+n,y,TRAVERSED);
 
}
 
 
 
 
 
 

--
Smile, it's the second best thing you can
do with your lips..........................................................
By the way...the First thing is ur KISS :-)


Prashant Bhargava-- www.excogitation.tk
                          or
www.hemantdesign.com/prashant

--~--~---------~--~----~------------~-------~--~----~
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