Mirror a Binary Tree
📖 Scenario: Imagine you have a family tree represented as a binary tree. You want to create a mirror image of this tree, flipping it left to right, like looking at it in a mirror.
🎯 Goal: You will build a program that creates a mirror of a given binary tree by swapping the left and right children of every node.
📋 What You'll Learn
Create a binary tree node class called
TreeNode with value, left, and right propertiesCreate a sample binary tree with exact nodes and structure
Write a function called
mirrorTree that mirrors the binary tree by swapping left and right children recursivelyPrint the tree nodes in level order after mirroring to show the mirrored structure
💡 Why This Matters
🌍 Real World
Mirroring binary trees is useful in graphics, image processing, and reversing hierarchical data structures.
💼 Career
Understanding tree manipulations like mirroring helps in coding interviews and software roles involving data structures.
Progress0 / 4 steps