lib/common/tree_utils.rb
# Depth first - recursive version
# will apply a block (3rd implicit parms) on each node using in-order
# traversal and collect the result into an array
#
Depth first - recursive version
will apply a block (3rd implicit parms) on each node using in-order
traversal and collect the result into an array
Depth first - recursive version will apply a block ( 3rd implicit parms ) on each node using in - order traversal and collect the result into an array
def _in_order(root, ary=[], lbd)
      if root.nil?
        ary
      else
        _in_order(root.lnode, ary, lbd)
        ary << lbd.call(root.val)
        _in_order(root.rnode, ary, lbd)
      end
    end
def _in_order ( root , ary = [ ] , lbd ) if root . nil? ary else _in_order ( root . lnode , ary , lbd ) ary << lbd . call ( root . val ) _in_order ( root . rnode , ary , lbd ) end end
Depth first - recursive version
will apply a block (3rd implicit parms) on each node using in-order
traversal and collect the result into an array
Depth first - recursive version will apply a block ( 3rd implicit parms ) on each node using in - order traversal and collect the result into an array
root
<not_specific>
ary
<not_specific>
lbd
<not_specific>