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...
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