Friday, 23 October 2015

VISITING ADJACENT NODES IN GRID




                (x-1,y-1)---------> (x-1,y)-----------> (x-1,y+1)
                  .                        .                          .       

                (x,y-1)                 (x,y)                   (x,y+1)  
                  .                        .                          .       
                (x+1,y-1)<----------(x+1,y)<---------   (x+1,y+1)
                  .                        .                          .


 Hectic Process to validate each point adjacent and jump onto that
 Same process to be done 8 times..

 Hence,
 We make two arrays to store the order of x,y components (delta)

         dx={-1,-1,-1,0,+1,+1,+1,0}
         dy={-1,0,+1,+1,+1,0,-1,-1}


    FOR i=0 -> 8
       validate(x+dx[i],y+dy[i])
       process(x+dx[i],y+dy[i])

No comments:

Post a Comment