lib/ruby_algorithms/algorithms/search/graphs/bst.rb
# This is pre order traversal (recursive implementation). Notice how the yield
# for visting the node is before the two recursive calls for left and right nodes
# respectively.
This is pre order traversal (recursive implementation). Notice how the yield
for visting the node is before the two recursive calls for left and right nodes
respectively.
This is pre order traversal ( recursive implementation ) . Notice how the yield for visting the node is before the two recursive calls for left and right nodes respectively .
def pre_order(node=@root, &block)
    return if node.nil?
    yield node
    in_order(node.left, &block)
    in_order(node.right, &block)
  end
def pre_order ( node = @root , & block ) return if node . nil? yield node in_order ( node . left , & block ) in_order ( node . right , & block ) end
This is pre order traversal (recursive implementation).
This is pre order traversal ( recursive implementation ) .
node
block