...

/

Solution Review: Copy Tree

Solution Review: Copy Tree

Let’s take a detailed look at the previous challenge’s solution.

Solution

The copy of a tree is generated by copying the nodes of the input tree at each level of traversal to the output tree. At each level of traversal, a new node is created and in this node, the value of the input tree node is copied. The left subtree is copied recursively and then ...