Skip to content

added catalan number in cpp in dynamic programming #6836

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RitikTiwary519
Copy link

Description

This PR adds the implementation of the Catalan Number algorithm using Dynamic Programming in C++ under the dynamic_programming directory.

Features:

  • Efficient Bottom-Up DP approach.
  • Time complexity reduced from exponential to O(n²).
  • Includes inline comments and example usage in main() for quick testing.

Time and Space Complexity

  • Time Complexity: O(n^2)
  • Space Complexity: O(n) (only stores the last n values)

Files Added

catalan_number.cpp

Related Issue

No specific issue linked, but this adds a key combinatorial algorithm often used in competitive programming and dynamic programming problem sets.


Sample Output

For n = 5, output will be:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant