Checking the left direction
if ( j - 1 >= 0 && maze [ i , j - 1 ] == 1 && visited [ i , j - 1 ] ) { Node temp1 = new Node ( i , j - 1 ) ; visited [ i , j - 1 ] = false ; s . Push ( temp1 ) ; } } else if ( d == 2 ) {