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

bintrees #1

Open
AlJohri opened this issue Oct 13, 2015 · 1 comment
Open

bintrees #1

AlJohri opened this issue Oct 13, 2015 · 1 comment

Comments

@AlJohri
Copy link

AlJohri commented Oct 13, 2015

cool library! I'm using this along with the bintrees library's AVLTree implementation
it's a pretty popular library - you might want to consider supporting it out of the box or adding a recipe to the readme

https://pypi.python.org/pypi/bintrees/2.0.2

here's how I use it:

from random import sample
from drawtree import drawtree

from bintrees.avltree import AVLTree, Node

class Tree(AVLTree):

    def __init__(self, items):
        items = {x:x for x in items} if isinstance(items, list) else items
        super(Tree, self).__init__(items)

    def display(self):
        drawtree.drawtree(self._root)

Node.val = property(lambda self: self.value) # rename value to val for drawtree

items = sample(range(100), 10)
print items
tree = Tree(items)
root = tree._root
tree.display()

thanks for making this! I was surprised there were so few good implementations of an ascii binary tree

@msbanik
Copy link
Owner

msbanik commented Oct 15, 2015

@AlJohri thanks for checking this out. I will add your recipe to readme.

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

No branches or pull requests

2 participants