Answers for "merge two binary trees sloved in ruby"

0

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
}
Posted by: Guest on June-03-2021

Browse Popular Code Answers by Language