diff --git a/lib/traverse.rb b/lib/traverse.rb index 145d6ef..48976d2 100644 --- a/lib/traverse.rb +++ b/lib/traverse.rb @@ -20,15 +20,21 @@ def self.root_only(tree) end def self.with_preorder(node) - # TODO + capture(node.data) + with_preorder(node.left_child) if node.left_child + with_preorder(node.right_child) if node.right_child end def self.with_inorder(node) - # TODO + with_inorder(node.left_child) if node.left_child + capture(node.data) + with_inorder(node.right_child) if node.right_child end def self.with_postorder(node) - # TODO + with_postorder(node.left_child) if node.left_child + with_postorder(node.right_child) if node.right_child + capture(node.data) end def self.with_levelorder(node)