Dynamic Programming question: Binomial Coefficient

SoccerBoss
Category:
Computer Science
Price: $5 USD

Question description

 A Binomial Coefficient C(n, k) is the number of distinct ways of selecting k objects from a set of n objects. There is only 1 way to select all n objects and only 1 way to select 0 objects. If we select the n’th object, then we must select k − 1 objects from the remaining n − 1 objects which can be done in C(n − 1, k − 1) ways. If we don’t select the n’th object, then we must select all k objects from the remaining n − 1 objects which can be done in C(n − 1, k) ways. These observations lead to the following recursive formula.

C(n, k) = {  

1 if k = 0, or k = n 

C(n − 1, k − 1) + C(n − 1, k) otherwise


Using this recursive formula in a straightforward recursive program would be horribly inefficient because you would be solving the same subproblems over and over again. Instead use this recursive formula to come up with a dynamic programming solution. What is the complexity of your algorithm in terms on n and k?


Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1831 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors