For the Fibonnacci serie that is described like follows: Fibo(0) = 0; Fibo(1)= 1; (base cases) .... Fibo(n) = Fibo(n-1)+Fibo(n-2) Thus: Fibo(2) = 1 + 0 = 1; Fibo(3) = 1 + 1 = 2;... This code computes N term of a Fibonacci serie, using 2 algorithmic techniques: Recursive and Rec-DProgramming, it also measures performance time. fibonacci.h #ifndef FIBONACCI-NUMBER_H_INCLUDED #define FIBONACCI-NUMBER_H_INCLUDED #include #include #include using namespace std; //Fibonnacci recursive int fiboRec(int n){ if(n==0) return 0; if(n (end - start).count() =0 && second>=0) return dp[n] = first + second; else return -6; } int launcherFiboDP(int k) { //dp = (int *) calloc( k+1, sizeof(*dp)); memset(dp, -6, sizeof(dp)); int n = k; ////// auto start = chrono::steady_clock::now(); int r = fiboDP(n); auto end = chrono::steady_clock::now(); ////// cout (end - start).count() > n; cout main.h #include "fibonacci.h...
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...
Description: we want to allow Github "Admin users" to create their Portfolio (s)" from their selected git url repositories. At first there would be a "Current" portfolio composed by many gits. It would be desirable to have the possibility of easy download (a batch process would create a macro link). UML design:
Comments
Post a Comment