Build a Binary Tree in Ruby
Posted in algorithms, ruby on January 7th, 2008 2 Comments »
Building algorithms in ruby is fun and rewarding. This binary tree doesn’t balance itself but it is simple and flexible using ruby blocks for visit and insert. Traversal style can be selected optionally to visit with :inorder, :preorder or :postorder.
Here’s your basic binary tree node representation, it holds a value and connects to a left [...]