Skip to content

Instantly share code, notes, and snippets.

@abriening
Created March 25, 2013 12:20
Show Gist options
  • Save abriening/5236761 to your computer and use it in GitHub Desktop.
Save abriening/5236761 to your computer and use it in GitHub Desktop.
Node = Struct.new(:value, :left, :right)
node = Node.new(24, Node.new(12, Node.new(10), Node.new(14)), Node.new(28, nil, Node.new(30)))
def values(node)
return [] if node.nil?
[values(node.left),
node.value,
values(node.right)].flatten
end
values(node)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment