I promised I was going to release the code of my random binary tree generator. It's now available on GitHub! It's a very simple implementation written in Python, and it also has a simple CLI interface.
You're free to fork the repo, optimize the code and make it even better and more featured!
Want some beautiful trees now? Link:

  • 1
  • 5
    yes, but does it scale, and which javascript frameworks does it implement?
  • 6
    @toriyuno No, it doesn't scale, I guess. And JS framework? I'm using PythonJS, a new framework that creates JavaScript frameworks and compiles them into Python, it came out tomorrow.
  • 3
    @iamavalos be sure to write a medium post about it. I'll spam it on hackernews.
  • 2
    I don't disagree that it isn't randomly created, but was the point of creating every branch with the same depth, rather than having a maximum depth and let the branches take a random depth? 🤔
  • 0
    @Thizizmyname i generates unbalanced b-trees
  • 3
    @stop but every node gets a random value from min to max and thus is not an ordered tree, or guarantees unique values in the nodes.

    So yes it's unbalanced, but since it's not a binary search tree you can't really balance it.

    I just think if you need a truly random tree in all cases, the depth should perhaps also be somewhat random
  • 0
    What is the probability distribution? E.g. does it pick uniformly from all binary trees of a given depth?
  • 1
  • 0
Your Job Suck?
Get a Better Job
Add Comment