Subscribe

Archive for January 7th, 2008

Build a Binary Tree in Ruby

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 […]