btree/ubtree.rb
def each_bf(node=@tree)
    return if node.nil?
    (1..node[:count]).each {|i| yield node}
    self.each(node[:left]) {|v| yield v}
    self.each(node[:right]) {|v| yield v}
  end
# breadth-first traversal, left to right
breadth-first traversal, left to right
breadth - first traversal left to right
def each_bf(node=@tree)
    return if node.nil?
    (1..node[:count]).each {|i| yield node}
    self.each(node[:left]) {|v| yield v}
    self.each(node[:right]) {|v| yield v}
  end
def each_bf ( node = @tree ) return if node . nil? ( 1 .. node [ :count ] ) . each { | i | yield node } self . each ( node [ :left ] ) { | v | yield v } self . each ( node [ :right ] ) { | v | yield v } end
breadth-first traversal, left to right
breadth - first traversal left to right
node