dibs: implement binary-search-tree by laurauzcategui · Pull Request #388 · exercism/python

@laurauzcategui

@kytrinyx

@laurauzcategui

@laurauzcategui

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

arcuru


class BST(object):
def __init__(self, root):
self.root = Node(root)

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...

arcuru

def __init__(self, root):
self.root = Node(root)

def insert(self, new_val):

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)

arcuru

else:
self.pre_insert(node.left, val)

def search(self, find_val):

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

@arcuru

@laurauzcategui

@stale

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.

@kytrinyx

@laurauzcategui Would you have a chance to finish this one up? We'd love to include it on the site.

@laurauzcategui

Hi @kytrinyx yes, sure thing. I'll be able to take a look probably next week and over the weekend.

Cheers,

@stale

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.

@devkabiir

@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?

@kytrinyx

@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.