NQueenProblem.java
/* This function checks whether a queen can be placed on chessBoard[row][col].
	This function is called recursively when "col" queens are placed
	already in columns from 0 to column -1. The left side might show if the queens are attacking.
	*/
This function checks whether a queen can be placed on chessBoard[row][col].
This function is called recursively when "col" queens are placed
already in columns from 0 to column -1. The left side might show if the queens are attacking.
This function checks whether a queen can be placed on chessBoard [ row ] [ col ] . This function is called recursively when " col " queens are placed already in columns from 0 to column - 1 . The left side might show if the queens are attacking .
boolean isSecured(int chessBoard[][], int row, int col) {
	int i, j;
	/* A for loop that checks the left side of attacks */
	for (i = 0; i < col; i++)
	if (chessBoard[row][i] == 1)
	return false;
	/* A for loop that checks the upper diagonal on left side of the board*/
	for (j = col, i = row; i >= 0 && j >= 0; i--, j--)
	if (chessBoard[i][j] == 1)
	return false;
	/* A for loop that checks the lower diagonal on left side of the board*/
	for (j = col, i = row; j >= 0 && i < N; i++, j--) {
	if (chessBoard[i][j] == 1)
	return false;
	   }
	return true;
	}
boolean isSecured ( int chessBoard [ ] [ ] , int row , int col ) { int i , j ; /* A for loop that checks the left side of attacks */ for ( i = 0 ; i < col ; i ++ ) if ( chessBoard [ row ] [ i ] == 1 ) return false ; /* A for loop that checks the upper diagonal on left side of the board*/ for ( j = col , i = row ; i >= 0 && j >= 0 ; i -- , j -- ) if ( chessBoard [ i ] [ j ] == 1 ) return false ; /* A for loop that checks the lower diagonal on left side of the board*/ for ( j = col , i = row ; j >= 0 && i < N ; i ++ , j -- ) { if ( chessBoard [ i ] [ j ] == 1 ) return false ; } return true ; }
This function checks whether a queen can be placed on chessBoard[row][col].
This function checks whether a queen can be placed on chessBoard [ row ] [ col ] .