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

add binary_tree_traversals.py to data_structures #3297

Merged
merged 31 commits into from
Oct 15, 2020
Merged

add binary_tree_traversals.py to data_structures #3297

merged 31 commits into from
Oct 15, 2020

Conversation

rajansh87
Copy link
Contributor

I have added some interesting binary tree traversing methods.

Describe your change:

In data_structures/binary_tree repository I have added a new file that includes some interesting methods for traversing a binary tree.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

I have added some interesting binary tree traversing methods.
@rajansh87
Copy link
Contributor Author

Can anyone help me out with what's the problem with my PR?

@cclauss
Copy link
Member

cclauss commented Oct 14, 2020

Run your code thru psf/black as discussed in CONTRIBUTING.md

@rajansh87
Copy link
Contributor Author

Any suggestions?

@cclauss
Copy link
Member

cclauss commented Oct 14, 2020

This will save you a ton of manual formatting...

python3 -m pip install black
black data_structures/binary_tree/binary_tree_traversals.py

@rajansh87
Copy link
Contributor Author

ok i'll try

@rajansh87
Copy link
Contributor Author

?

@cclauss
Copy link
Member

cclauss commented Oct 14, 2020

data_structures/binary_tree/binary_tree_traversals.py:24:89: E501 line too long (89 > 88 characters)
data_structures/binary_tree/binary_tree_traversals.py:34:89: E501 line too long (91 > 88 characters)

@rajansh87
Copy link
Contributor Author

can you explain?

@cclauss
Copy link
Member

cclauss commented Oct 14, 2020

Lines are not allowed to be longer than 88 characters max. Lines 24 and 34 are too long and must be wrapped.

@TravisBuddy
Copy link

Travis tests have failed

Hey @rajansh87,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 6838e980-0e68-11eb-964d-5d54b4986782

@TravisBuddy
Copy link

Travis tests have failed

Hey @rajansh87,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: ade5d380-0e68-11eb-964d-5d54b4986782

@rajansh87
Copy link
Contributor Author

I think we should not make further changes as it might becomeworse...

@cclauss
Copy link
Member

cclauss commented Oct 15, 2020

Please do not give up... We are really close. Our testing now accepts trailing spaces inside triple quotes so your doctests should now work if your answers have one trailing space.

@rajansh87
Copy link
Contributor Author

ok

@rajansh87
Copy link
Contributor Author

what to do next?

@rajansh87
Copy link
Contributor Author

why is this failing to build, can we see whats are the logs or what is error?

@cclauss cclauss requested a review from dhruvmanila as a code owner October 15, 2020 10:11
@cclauss
Copy link
Member

cclauss commented Oct 15, 2020

I hope this will be 100% green with doctests and type hints so we can land this PR.

Now I remember why I said that algorithmic functions should not print()... It makes testing too hard.

@rajansh87
Copy link
Contributor Author

Yeah, Now i understood.

@TravisBuddy
Copy link

Travis tests have failed

Hey @rajansh87,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 76c03820-0ecf-11eb-9bff-abeacd856cb9

@rajansh87
Copy link
Contributor Author

?

@dhruvmanila
Copy link
Member

I think our entire repository is based on the code style of black. We should fix the file instead of ignoring it in black.

@cclauss cclauss merged commit e035c61 into TheAlgorithms:master Oct 15, 2020
@cclauss
Copy link
Member

cclauss commented Oct 15, 2020

I will revert the black change in a separate PR.

@dhruvmanila
Copy link
Member

Black is actually not changing the file in the current state.

$ black --check binary_tree_traversals.py
All done! ✨ 🍰 ✨
1 file would be left unchanged.

@cclauss
Copy link
Member

cclauss commented Oct 15, 2020

Yes, See #3318

@rajansh87
Copy link
Contributor Author

thanks, guys it was really very interesting and helpful of you because this was my first time when I was contributing to such a huge repo. Learned a lot of kinds of stuff which I had not any idea. Thanks, @cclauss, and @dhruvmanila for helping me troughout.

@cclauss
Copy link
Member

cclauss commented Oct 15, 2020

This was work well done. Please come back with another algoritym soon.

There are still doctests missing from many of those functions if you can figure out how to add them.

@rajansh87
Copy link
Contributor Author

yeah, i was looking at that only. Any suggestions!

@cclauss
Copy link
Member

cclauss commented Oct 15, 2020

Perhaps yield node.data as you traverse the tree and then print(", ".join(my_yielding_function(root)))

Using yield is always a bit of a mind-bender.

stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* add binary_tree_traversals.py to data_structures

I have added some interesting binary tree traversing methods.

* Fixed error

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Doctests and type hints

* Add spaces

* Update binary_tree_traversals.py

* black exclude data_structures/binary_tree/binary_tree_traversals.py

* Add spaces again

* Update binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
* add binary_tree_traversals.py to data_structures

I have added some interesting binary tree traversing methods.

* Fixed error

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Update data_structures/binary_tree/binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_tree_traversals.py

* Doctests and type hints

* Add spaces

* Update binary_tree_traversals.py

* black exclude data_structures/binary_tree/binary_tree_traversals.py

* Add spaces again

* Update binary_tree_traversals.py

Co-authored-by: Christian Clauss <cclauss@me.com>
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.

4 participants