Question: Write a recursive method(Code) static void mirrorTree(node root) This will take a tree as input and then change the tree such that it becomes
Write a recursive method(Code) static void mirrorTree(node root) This will take a tree as input and then change the tree such that it becomes a mirror of itself. We have the following methods implemented (you can use them and assume we coded somewhere else): getLeft(), getRight(), setLeft(), setRight(), getValue(). All the values in a node are integers. [Hint: Use them, and think how you would write when the tree only has 2 children] Example: (6) (3) (8) (3 279 972 (6) 8
Step by Step Solution
There are 3 Steps involved in it
Pseudocode MirrorTreeroot rootmirrorTreeUtilroot Pseudocode MirrorTreeUtiltree 1 Call MirrorTreeUtil for leftsubtree ie MirrorTreeUtilleftsubtree 2 Ca... View full answer
Get step-by-step solutions from verified subject matter experts
