

1. Fill in the missing code in the recursive exploreQueen method
2. How would you change this to stop at one solution? 

/**
 * taken from Building Java programs and http://www.fas.harvard.edu/~cscie119/lectures/recursion.pdf
 * 
 */public class Queens3
{
    public static void main (String[] args)
    {
        int size = 4;
        char[][] b = new char[size][size];
        for (int x = 0; x < size; x++){
            for (int y = 0; y < size ; y++){
                b[x][y] = '-';
            }
        }
        exploreQueen(0,b);
    }

    public static boolean exploreQueen(int x,   char[][] b){
        // if this is a solution, report it
        if (  x >= b.length){
            System.out.println("Here is one answer:" );
            for (int x1 = 0; x1 < b.length; x1++){
                for (int y1 = 0; y1 <b[0].length; y1++){
                    System.out.print(" " + b[x1][y1]  );
                }
                System.out.println();
            }
            return true;
        }
        else {
            // for each available choice
            for (int y = 0; y < b[0].length; y++)
            {
                // if this is not a dead end
                  _______________________________________
                  _______________________________________
                  _______________________________________
                  _______________________________________                )
                { // use a recursive call to explore that choice
                    //make the choice
 				______________________________
                    // recursively explore subsequent choices
                    __________________________________ ;
                    // undo the choice
                    ___________________________________
                }
            }
        }
        return false;
    }

    public static boolean isSafeX(int x, int y,   char[][] b){ 
        if(   x <0  ){
            return true;}
        else if (   b[x][y] == 'Q') {
            return false;}
        else {
            return   isSafeX(x-1,y,b);
        }
    }

    public static boolean isSafeY(int x, int y,   char[][] b){ 
        if(   y <0 ){
            return true;}
        else if (   b[x][y] == 'Q') {
            return false;}
        else {
            return   isSafeY(x,y-1,b);}
    }

    public static boolean isSafeDiagLeft(int x, int y,   char[][] b){ 
        if(  y <0        ||  x <0 ){
            return true;}
        else if (   b[x][y] == 'Q') {
            return false;}
        else {
            return   isSafeDiagLeft(x-1,y-1,b);}
    }

    public static boolean isSafeDiagRight(int x, int y,   char[][] b){ 
        if(  y >= b[0].length        ||  x < 0   ){
            return true;}
        else if (   b[x][y] == 'Q') {
            return false;}
        else {
            return   isSafeDiagRight(x-1,y+1,b);}
    }
}