Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Problem A. Binomial Coefficient | Problems
Dynamic Programming
course content

Contenido del Curso

Dynamic Programming

Dynamic Programming

1. Intro to Dynamic Programming
2. Problems
3. Solutions

Problem A. Binomial Coefficient

The tasks in this section contain test function calls. Please do not change this code; otherwise, the assignment may not be accepted.

In previous sections, we solved the problems that can be described as functions with 1 parameter (fib(n), rabbit(n)). Sometimes, the function depends on 2 or more parameters, for example, this one.

Tarea

Create the program to calculate Binomial coefficient C(n, k) using dynamic programming. Since the function contains two parameters, the problem requires a two-dimensional array dp[n+1][n+1] to store the values.

  1. Define the base cases: C(n,0) = C(n,n) = 1
  2. Use the rule:

C(n,k) = C(n-1,k-1) + C(n-1,k).

Use Optimal Substructure and Overlapping Subproblems principles. If you’re unsure about how to store sub-solutions, open Hint.

Example 1. n=3, k=2 -> res = 3

Example2. n=10, k=4 -> res = 210

Tarea

Create the program to calculate Binomial coefficient C(n, k) using dynamic programming. Since the function contains two parameters, the problem requires a two-dimensional array dp[n+1][n+1] to store the values.

  1. Define the base cases: C(n,0) = C(n,n) = 1
  2. Use the rule:

C(n,k) = C(n-1,k-1) + C(n-1,k).

Use Optimal Substructure and Overlapping Subproblems principles. If you’re unsure about how to store sub-solutions, open Hint.

Example 1. n=3, k=2 -> res = 3

Example2. n=10, k=4 -> res = 210

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 1
toggle bottom row

Problem A. Binomial Coefficient

The tasks in this section contain test function calls. Please do not change this code; otherwise, the assignment may not be accepted.

In previous sections, we solved the problems that can be described as functions with 1 parameter (fib(n), rabbit(n)). Sometimes, the function depends on 2 or more parameters, for example, this one.

Tarea

Create the program to calculate Binomial coefficient C(n, k) using dynamic programming. Since the function contains two parameters, the problem requires a two-dimensional array dp[n+1][n+1] to store the values.

  1. Define the base cases: C(n,0) = C(n,n) = 1
  2. Use the rule:

C(n,k) = C(n-1,k-1) + C(n-1,k).

Use Optimal Substructure and Overlapping Subproblems principles. If you’re unsure about how to store sub-solutions, open Hint.

Example 1. n=3, k=2 -> res = 3

Example2. n=10, k=4 -> res = 210

Tarea

Create the program to calculate Binomial coefficient C(n, k) using dynamic programming. Since the function contains two parameters, the problem requires a two-dimensional array dp[n+1][n+1] to store the values.

  1. Define the base cases: C(n,0) = C(n,n) = 1
  2. Use the rule:

C(n,k) = C(n-1,k-1) + C(n-1,k).

Use Optimal Substructure and Overlapping Subproblems principles. If you’re unsure about how to store sub-solutions, open Hint.

Example 1. n=3, k=2 -> res = 3

Example2. n=10, k=4 -> res = 210

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 1
toggle bottom row

Problem A. Binomial Coefficient

The tasks in this section contain test function calls. Please do not change this code; otherwise, the assignment may not be accepted.

In previous sections, we solved the problems that can be described as functions with 1 parameter (fib(n), rabbit(n)). Sometimes, the function depends on 2 or more parameters, for example, this one.

Tarea

Create the program to calculate Binomial coefficient C(n, k) using dynamic programming. Since the function contains two parameters, the problem requires a two-dimensional array dp[n+1][n+1] to store the values.

  1. Define the base cases: C(n,0) = C(n,n) = 1
  2. Use the rule:

C(n,k) = C(n-1,k-1) + C(n-1,k).

Use Optimal Substructure and Overlapping Subproblems principles. If you’re unsure about how to store sub-solutions, open Hint.

Example 1. n=3, k=2 -> res = 3

Example2. n=10, k=4 -> res = 210

Tarea

Create the program to calculate Binomial coefficient C(n, k) using dynamic programming. Since the function contains two parameters, the problem requires a two-dimensional array dp[n+1][n+1] to store the values.

  1. Define the base cases: C(n,0) = C(n,n) = 1
  2. Use the rule:

C(n,k) = C(n-1,k-1) + C(n-1,k).

Use Optimal Substructure and Overlapping Subproblems principles. If you’re unsure about how to store sub-solutions, open Hint.

Example 1. n=3, k=2 -> res = 3

Example2. n=10, k=4 -> res = 210

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

The tasks in this section contain test function calls. Please do not change this code; otherwise, the assignment may not be accepted.

In previous sections, we solved the problems that can be described as functions with 1 parameter (fib(n), rabbit(n)). Sometimes, the function depends on 2 or more parameters, for example, this one.

Tarea

Create the program to calculate Binomial coefficient C(n, k) using dynamic programming. Since the function contains two parameters, the problem requires a two-dimensional array dp[n+1][n+1] to store the values.

  1. Define the base cases: C(n,0) = C(n,n) = 1
  2. Use the rule:

C(n,k) = C(n-1,k-1) + C(n-1,k).

Use Optimal Substructure and Overlapping Subproblems principles. If you’re unsure about how to store sub-solutions, open Hint.

Example 1. n=3, k=2 -> res = 3

Example2. n=10, k=4 -> res = 210

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 1
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt