This function is supposed to return the binomial coefficients for N and k using dynamic programming, but it does not return the correct result. Does anybody know what is wrong with the code?Code:int dynamicBinomial(int N, int k) { vector< vector<int> >table(N,vector<int>(k)); for (int j = 0; j < N; j++) table[j][0] = 1; for (int i = 0; i < N; i++) { for (int j = 0; j < k; j++) { table[i][j] = table[i-1][j-1] + table[i-1][j]; } } return table[N-1][k-1]; }




Reply With Quote