YCP Logo Assignment 6: Binomial Coefficient

Due: Tuesday, November 25th by 11:59 PM

Binomial Coefficient

The binomial cooefficient C(n,k), often written "n choose k", is the number of ways to pick a subset of k elements from a collection of n elements. It may be defined recursively as follows:

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

Getting Started

Import the file CS201_Assign6.zip into your Eclipse workspace. You will implement the compute method of the classes NaiveRecursive and DynamicProgramming.

As the names suggest, NaiveRecursive should be a literal recursive implementation of the binomial coefficient function, and DynamicProgramming should implement the binomial coefficient function using dynamic programming to avoid repeatedly solving identical subproblems.

Because the binomial coefficient function takes two parameters, n and k, you will probably want your memoization table to be a two-dimensional array.


Run the main method of the TestDriver class by right-clicking on TestDriver.java and choosing Run As->Java Application. The test driver solves C(n,k) for all values of k 0..n, for n=25, and measures the number of milliseconds needed to solve each problem. While the naive recursive implementation will take an appreciable amount of time, the dynamic programming implementation should execute fairly quickly.


Export your project as a zip file (File->Export...->Archive File) and upload it to the submission server as assign6. The URL of the server is