Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To calculate nCr using Dynamic Programmimg #43

Closed
2 tasks
niranjansy opened this issue Oct 1, 2019 · 2 comments
Closed
2 tasks

To calculate nCr using Dynamic Programmimg #43

niranjansy opened this issue Oct 1, 2019 · 2 comments
Labels
Algorithms Algorithms Beginner Easy level tasks good first issue Good for newcomers Hacktoberfest For hacktoberfest

Comments

@niranjansy
Copy link

niranjansy commented Oct 1, 2019

Description
The objective of this program is to calculate the value of nCr for given values of n and r. This can be done using the recursive formula:
nCr = (n-1)Cr + (n-1)C(r-1)
For big values of n and r, implementing this using a recursive function takes a very long time since there will be many overlapping sub-problems. So a solution to this would be to use dynamic programming, where we store intermediate results in a table, so that we do not have to compute the same sub-problem over and over again. The task here is to implement the above idea using dynamic programming.

Details
• Technical Specifications: Use C++ or C language for coding
• Type of issue: Single
• Time Limit: One day

Issue Requirements / Progress:

  • Writing a dynamic programmimg algorithm to perform the above function

  • For bigger values of n and r, since the output will be beyond the range of integer numbers, output the answer mod (10^9 + 7).

Resources

Directory Structure
Create a folder named '43'(43 as in the issue number) in the 'algorithms' folder. Name your program file as ‘nCrDynProg.cpp' or ‘nCrDynProg.c' accordingly. Add this program file to the folder '/algorithms/43'.

Note
Please claim the issue first by commenting here before starting to work on it.
Point of contact
While submitting a PR, request a review from Niranjan S Yadiyala @(niranjansy).

@SaurabhAgarwala SaurabhAgarwala added the Hacktoberfest For hacktoberfest label Oct 1, 2019
@fsabr
Copy link
Contributor

fsabr commented Oct 1, 2019

I would like to take this up.
Could you give the constraints on 'n' and 'r'?

@niranjansy
Copy link
Author

0 <= r <= n <=1000

@fsabr fsabr mentioned this issue Oct 1, 2019
@hpgupt hpgupt added Algorithms Algorithms Beginner Easy level tasks good first issue Good for newcomers labels Oct 2, 2019
@fsabr fsabr mentioned this issue Oct 2, 2019
@Akshayy99 Akshayy99 mentioned this issue Oct 2, 2019
5 tasks
@fsabr fsabr mentioned this issue Oct 3, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algorithms Algorithms Beginner Easy level tasks good first issue Good for newcomers Hacktoberfest For hacktoberfest
Projects
None yet
Development

No branches or pull requests

4 participants