Challenge: Copy Mirror Tree
Let’s copy a binary tree such that it mirrors the original tree.
We'll cover the following
Problem
Given a binary tree, copy its values to create another tree that is a mirror image of the original tree.
Input
A binary tree.
Output
A new binary tree that is a mirror of the given binary tree.
Sample input
The root node t.root
of a binary tree will be our input for which we have to generate a mirror copy tree. We’ll generate this new tree by using the copyMirrorTree()
function.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.