-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Added tree_height.cpp in dynamic_programming directory #721
Conversation
@cclauss Its fixed. |
@cclauss Any idea what can we do to add tests for incoming checks, we can tests the working for this by just looking at it!! |
Co-Authored-By: Christian Clauss <cclauss@me.com>
There are multiple unit test frameworks for C++. So someone who really knows the current state of C++ (i.e. not me) needs to pick one of them and then I can help with the GitHub Actions to enforce the rule that every new submission must have tests and pass them. TheAlgorithms/Python does this and pytest currently runs >500 tests on every submission. If you want to proceed, please open a new issue. |
@cclauss Should we merge this PR? |
It has my approval but let's let @bhaumikmistry decide. |
Co-Authored-By: Christian Clauss <cclauss@me.com>
LGTM. Can be merged at any time. |
Description of Change
Added finding the height of the valid tree in O(n) using bottom - up dp approach.
where n is a number of nodes.
A valid tree contain exactly n-1 edges when n is number of nodes.
Sample Input: -
4
1 2
1 3
2 3
Hence the height of the tree is 3
Checklist
Notes: