Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

merge two binary trees sloved in ruby

treeNode mergedBinaryTree(treeNode root1, treeNode root2)
{
     if(root1.value == NULL)
        return root2
     if(root2.value == NULL)
        return root1
     root1.value += root2.value
     root1.left = mergedBinaryTree(root1.left, root2.left)
     root1.right = mergedBinaryTree(root1.right, root1.right)
     return root1
}
Source by afteracademy.com #
 
PREVIOUS NEXT
Tagged: #merge #binary #trees #sloved #ruby
ADD COMMENT
Topic
Name
7+1 =