Mirror Tree
Problem
Given a Binary Tree, convert it into its mirror.
Solution Approach
Expected Time complexity:
Click - to see solution code
- C++
void mirror(struct Node* node) {
if (!node) return;
struct Node* t1 = node->left;
struct Node* t2 = node->right;
node->left = t2;
node->right = t1;
mirror(node->left);
mirror(node->right);
}