Given a BST, create a mirror of it.
Problem
Change a tree so that the roles of the left and right pointers are swapped at every node. Example
So the tree…
4
/ \
2 5
/ \
1 3
is changed to…
4
/ \
5 2
/ \
3 1
The solution is short, but very recursive. As it happens, this can be accomplished without changing the root node pointer, so the return-the-new-root construct is not necessary.
[Read More]