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

binary_search_tree.py: Add BST data structure #122

Closed
wants to merge 3 commits into from
Closed

binary_search_tree.py: Add BST data structure #122

wants to merge 3 commits into from

Conversation

gabrieldluca
Copy link

This adds Binary Search Tree algorithm which keeps values in sorted
order, so that lookup and other operations can use the principles of
binary search while traversing the tree from root to leaf.

Closes #51

By submitting this pull request I confirm I've read and complied with the
below declarations.

  • I have read the Contribution guidelines and I am confident that my PR reflects them.
  • I have followed the commit guidelines for this project.
  • My code follows the standard code structure.
  • This pull request has a descriptive title. For example, {Tag}: Add {Algorithm/DS name} [{Language}], not Update README.md or Added new code.
  • This pull request will be closed if I fail to update it even once in a continuous time span of 7 days.
  • This pull request shall only be reviewed and merged once all the checks passes. No maintainer or supporter shall be obliged to review it before this condition is met.
  • I have mentioned the issue number correctly (with hyperlink) in this pull request description.

After you submit your pull request, DO NOT click the 'Update Branch' button.

@gabrieldluca gabrieldluca changed the title binary_search_tree.py: Add BST algorithm [Python] binary_search_tree.py: Add BST data structure [Python] Oct 1, 2018
@gabrieldluca
Copy link
Author

@sangamcse Please review.

@sangamcse
Copy link
Member

@sangamcse rebase

@sangamcse
Copy link
Member

Hey! I'm GitMate.io! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost permanently ⚠️

@sangamcse
Copy link
Member

Automated rebase with GitMate.io was successful! 🎉

@sangamcse
Copy link
Member

Update in Readme and code comments needed.

"""
Class that represent a leaf node of a binary tree.
"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: python spacing.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpikx6la4g/binary_search_tree/Python/binary_search_tree.py
+++ b/tmp/tmpikx6la4g/binary_search_tree/Python/binary_search_tree.py
@@ -2,7 +2,7 @@
     """
     Class that represent a leaf node of a binary tree.
     """
-    
+
     def __init__(self, value=None, leftChild=None, rightChild=None):
         self.value = value
         self.leftChild = leftChild

Class that represents a Binary Search Tree
<https://en.wikipedia.org/wiki/Binary_search_tree>.
"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: python spacing.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpikx6la4g/binary_search_tree/Python/binary_search_tree.py
+++ b/tmp/tmpikx6la4g/binary_search_tree/Python/binary_search_tree.py
@@ -27,7 +27,7 @@
     Class that represents a Binary Search Tree
     <https://en.wikipedia.org/wiki/Binary_search_tree>.
     """
-    
+
     def __init__(self):
         self.root = None
         


def __init__(self):
self.root = None

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: python spacing.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpikx6la4g/binary_search_tree/Python/binary_search_tree.py
+++ b/tmp/tmpikx6la4g/binary_search_tree/Python/binary_search_tree.py
@@ -30,7 +30,7 @@
     
     def __init__(self):
         self.root = None
-        
+
     def __del__(self):
         del self.root
 

else:
currentNode.value = value
return currentNode

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

Origin: SpaceConsistencyBear, Section: python spacing.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpikx6la4g/binary_search_tree/Python/binary_search_tree.py
+++ b/tmp/tmpikx6la4g/binary_search_tree/Python/binary_search_tree.py
@@ -60,7 +60,7 @@
         else:
             currentNode.value = value
         return currentNode
-        
+
 def main():
     values = [1, 2, 0, 1.5, 0.5]
     tree = BST()

@gabrieldluca
Copy link
Author

@sangamcse I've updated the code problems and updated the README file. Please check again once you're ready.

@sangamcse
Copy link
Member

@sangamcse rebase

@sangamcse
Copy link
Member

Hey! I'm GitMate.io! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost permanently ⚠️

@sangamcse
Copy link
Member

@gabrieldluca, I tried rebasing your repo but it failed. Kindly rebase it locally and push it again on success.

@gabrieldluca
Copy link
Author

@sangamcse Done!

@sangamcse sangamcse changed the title binary_search_tree.py: Add BST data structure [Python] binary_search_tree.py: Add BST data structure Oct 3, 2018
@sangamcse
Copy link
Member

@sangamcse rebase

@sangamcse
Copy link
Member

Hey! I'm GitMate.io! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost permanently ⚠️

Gabriel D'Luca and others added 3 commits October 3, 2018 17:47
This adds Binary Search Tree data structure which keeps values in
sorted order, so that lookup and other operations can use the
principles of binary search while traversing the tree from root
to leaf.

Closes #51
@sangamcse
Copy link
Member

Automated rebase with GitMate.io was successful! 🎉

@sangamcse
Copy link
Member

@sangamcse rebase

@sangamcse
Copy link
Member

Hey! I'm GitMate.io! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost permanently ⚠️

@sangamcse
Copy link
Member

Automated rebase failed! Please rebase your pull request manually via the command line.

Reason:

Command: git rebase base/master

Exit Code: 128

Cause:

.git/rebase-apply/patch:20: trailing whitespace.
class Leaf:
.git/rebase-apply/patch:21: trailing whitespace.
    """
.git/rebase-apply/patch:22: trailing whitespace.
    Class that represent a leaf node of a binary tree.
.git/rebase-apply/patch:23: trailing whitespace.
    """
.git/rebase-apply/patch:24: trailing whitespace.

warning: squelched 74 whitespace errors
warning: 79 lines add whitespace errors.
error: Failed to merge in the changes.


@sangamcse
Copy link
Member

sangamcse commented Oct 4, 2018

@gabrieldluca the PR is approved but we need to rebase it before merging it. So rebase it manually and remind me on gitter once it is done https://gitter.im/NITSkmOS/algo

Note: Do not open any PR to any organization from the master branch because it makes difficult to maintain the PR.

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

Successfully merging this pull request may close these issues.

[Data Structure] Binary Search Tree [Python]
2 participants