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

Added tree_height.cpp in dynamic_programming directory #721

Merged
merged 11 commits into from
Apr 21, 2020
Merged

Added tree_height.cpp in dynamic_programming directory #721

merged 11 commits into from
Apr 21, 2020

Conversation

mann2108
Copy link
Member

@mann2108 mann2108 commented Apr 17, 2020

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

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • Sort by alphabetical order
  • I acknowledge that all my contributions will be made under the project's license.

Notes:

@mann2108
Copy link
Member Author

Four errors found in https://github.com/TheAlgorithms/C-Plus-Plus/actions

@cclauss Its fixed.

@bhaumikmistry
Copy link
Contributor

@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>
@cclauss
Copy link
Member

cclauss commented Apr 18, 2020

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.

@mann2108
Copy link
Member Author

@cclauss Should we merge this PR?

@cclauss
Copy link
Member

cclauss commented Apr 20, 2020

It has my approval but let's let @bhaumikmistry decide.

dynamic_programming/tree_height.cpp Show resolved Hide resolved
@poyea
Copy link
Member

poyea commented Apr 20, 2020

LGTM. Can be merged at any time.

@poyea poyea merged commit 4fe5ad6 into TheAlgorithms:master Apr 21, 2020
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.

5 participants