Provide pseudocode using a dynamic programming algorithm for

Provide pseudo-code using a dynamic programming algorithm for the evaluation of the number of combinations of n items taken k at a time. Use the following recurrence relation: C(n, k) = ( 1 : k = n or k = 0 C(n 1, k 1) + C(n 1, k) : otherwise Please write pseudo-code (not Java). No variable declarations, output statements or semi-colons needed.

Solution

for i = 0:n-1
{
   c[i][0]=1
   for j = i+1:n
   {
       c[i][j] = 0
   }
}

for i = 1:n
{
   for j = i:1:-1
   {
       c[i][j] = c[i-1][j] + c[i-1][j-1]
   }
}

Provide pseudo-code using a dynamic programming algorithm for the evaluation of the number of combinations of n items taken k at a time. Use the following recur

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site