1. Binomial Coefficient and World series problem
using Dynamic Programming approach
Submitted by – Samyak Jain (MCA/25014/2022)
Abhishek Ahlawat (MCA/25017/2022) Submitted to – Madhavi Sinha Mam
2. What is Binomial Coefficient?
Binomial Coefficient is used to denote the number of
possible ways to choose a subset of object of a given
number from a larger set.
4. Suppose , we have to find the coefficient of the (x + y)^100 , then it will be very
difficult to find the binomial coefficient using Pascal’s Triangle.
So, Pascal drives the formula to find the binomial coefficient of any (x + y)^n .
8. WORLD SERIES PROBLEM
Teams A and B compete in a series of games.
• The winner is the first team to win n games.
• The series ends as soon as the winner is decided.
• At most 2n–1 games are played.
We assume that there are no tied games, that the result of each match are
independent .
There is a constant chance p that team A will win and hence a constant probability
q = 1 – p that team B would win for every given match.
9. RECURSIVE FORMULA
Given that in a single contest between team A and team B, the probability team A wins is
p,(and the probability that team B wins is 1 – p, so we are precluding ties),what is the
probability in i+j games played, that team A will win i games and team B will win j games.
Let this value be denoted by the function p(i,j).
In order to obtain the dynamic programming solution, we must first develop a
recursive formula for the function p(i,j). In order for team A to have won i games
and team B to have won j games, before the last game, either A won i and B won
j-1 OR A won i-1 and B won j. Here is a recursive formula that captures that
reasoning:
p(i, j) = p(i, j - 1)(1 - p) + p(i -1, j) p
10. WORLD SERIES DYNAMIC PROGRAMMING
P(i, j) is the probability that the team A will win if it gets i more victories
and the team B will win if it gets j more victories.
For example, before the first game off the series the probability that
team A will be the overall winner is P(n, n): both teams still need n
victories.
If team A has already won all the matches it needs, then it is of course
certain that they will win the series:
P(0, i) = 1; 1 ≤ I ≤ n.
Similarly , if team B require 0 victories, then they have already won the
series , and the probability that team A will be overall winner is zero .
P(i,0) = 0 ; 1 ≤ I ≤ n.
11. Since, team A win any given match with probability p and lose it with
probability q .
P(i,j) = pP(i-1,j) + qP(i,j-1); i≥1 , j≥1.
Thus we can compute p(i,j) as follows .
Function P(i,j)
if i = 0 then return 1
else if j = 0 then return 0
else return pP(i-1,j) + qP(i,j-1)
12. Let T(k) be the time needed in the worst case to calculate P(i, j), where
k = i + j. With this method, we see that
T(k) is therefore in O(2n),
which is O(4n), if i=j=n
13. To speed up the algorithm , we declare an array of appropriate size and then
fill the entries .
14.
15. REFERENCES
WORLD SERIES PROBLEM
http://cs360.cs.ua.edu/lectures/37%20Dynamic%20Programming.pdf
https://cerocks.files.wordpress.com/2011/03/fundamentals-of-algorithmics-
brassard_ingles.pdf
BINOMIAL COEFFICIENT
https://www.youtube.com/watch?v=GmB0cIY7uMk
https://www.youtube.com/watch?v=eAMCL-mMmcY