N-Queens problem consist into place N Queens on a chess board so that any of the queens is able to kill anyother. (Move: Horizontal, Diagonal). To find the solution we use Backtracking technique , code is also documented. nqueens.h #ifndef NQUEENS_H_INCLUDED #define NQUEENS_H_INCLUDED #include //Abstract class using namespace std; class NBacktracking { public: NBacktracking( int n, int defValue){ N = n; defVal = defValue; //board = this->generateBoard(); ld = new int[n*n]; rd = new int[n*n]; cl = new int[n*n]; } virtual ~NBacktracking(){} virtual bool solve(){} virtual bool solveUtil(int **board,int level){} int** generateBoard(){ int **b = new int*[N]; for(int i = 0; i //NQueens problem class NQueens : public NBacktracking { public: NQueens(int n,int defValue):NBacktracking(n,defValue){} virtual ~NQueens() {} virtual bool solve(); virtual bool solveUtil(int **board, int col); virtual void printSolution...
Concerning post discussion: modelling in referential model, what answers do I have?
ReplyDeleteFrom my point of view in a top-down approach it's right. You have to solve how data from my requirements can be put in that referential model and can be fine grained in differents normal forms