-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
dibs: implement binary-search-tree #388
dibs: implement binary-search-tree #388
Conversation
Also @behrtam , I think as I rebased the upstream, I brought your changes from there to my branch. I hope this is not a problem. Just wanted to update my branch with latest changes from the upstream |
|
||
class BST(object): | ||
def __init__(self, root): | ||
self.root = Node(root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requiring an initial value for the BST seems like a very odd design choice...
def __init__(self, root): | ||
self.root = Node(root) | ||
|
||
def insert(self, new_val): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already wrote this function below. self.pre_insert(self.root, new_val)
else: | ||
self.pre_insert(node.left, val) | ||
|
||
def search(self, find_val): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This search function is probably a little easier to read if you do something like this:
cur = self.root
while cur:
if find_val == cur.value:
return True
cur = cur.left if find_val < cur.value else cur.right
return False
@laurauzcategui You can clean up the extra git commits by resetting instead of rebasing. It's explained here - https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#resetting-master You also need to add a few more tests. Right now you only ever test inserting things into the left nodes. You should at least add some tests to try to insert a more complex tree and values that are already in the tree. |
Thanks @patricksjackson will check it over the weekend 👍 |
This issue has been automatically marked as `on hiatus because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@laurauzcategui Would you have a chance to finish this one up? We'd love to include it on the site. |
Hi @kytrinyx yes, sure thing. I'll be able to take a look probably next week and over the weekend. Cheers, |
This issue has been automatically marked as |
@kytrinyx Looks like issue was automatically closed, but I have a BST implementation ready in python2 I would like to include this exercise. Can you assign this issue to me and add hacktoberfest label too? |
@kabiir that's great. Please submit your pull request. It doesn't need to have an open issue or a hacktoberfest label in order to be counted towards your Hacktoberfest metrics. |
I will implement binary-search-tree in : Binary Search Tree - X-Common