Binary Search Tree

For Nature of Code this week, I recreated the binary tree in three.js. Each time the program runs, it creates 50 randomly-sized spheres. They are sorted, sized and colored based on their value.

Here’s the code on Github.

Here are a few examples of the output.

b2.mp4

c2.mp4

a2.mp4

I also tried to do this with the population of the 50 US states as the values behind each sphere’s size, but the results weren’t that interesting, so I dropped it.