Mirror Binary Tree in Data Structure
A mirror binary tree is a binary tree in a data structure in which the left and right child of every node are mirror images of each other. This means that the left subtree of a node is the mirror image of the right subtree of the node, and vice versa. This simple meaning is that a tree whose left part of root node is exact copy of it left part from the root node of a Binary tree structure.
For example, consider the following binary tree as:
![Mirror Binary Tree in Data Structure/>
<!-- /wp:html -->
<!-- wp:paragraph -->
<p>Figure: View of Mirror representation of Binary Tree</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>This binary tree on left side and mirrored binary tree on left side, as left side root node is shown on right side of mirror binary tree and vice- versa.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>This binary tree is not a mirror tree because the left and right subtrees of the root node are not mirror images of each other. However, if we swap the left and right subtrees of every node in this tree, we get the following mirror tree as:</p>
<!-- /wp:paragraph -->
<!-- wp:code -->
<pre class=](https://static.tutorialandexample.com/data-structure/mirror-binary-tree-in-data-structure1.png)
1
/ \
3 2
/ \ /\
7 6 5 4
In this tree, the left and right subtrees of every node are mirror images of each other.
It's important to note that a mirror tree is not the same as a symmetrical tree, in which the left and right subtrees of every node are identical. A mirror tree is a tree in which the left and right subtrees are mirror images of each other, but they do not have to be identical.
![Mirror Binary Tree in Data Structure/>
<!-- /wp:html -->
<!-- wp:paragraph -->
<p>Figure: Mirror Binary tree</p>
<!-- /wp:paragraph -->
<!-- wp:heading -->
<h2>Usage of Mirror binary tree</h2>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p>There are several ways in which mirror binary trees can be used as:</p>
<!-- /wp:paragraph -->
<!-- wp:list {](https://static.tutorialandexample.com/data-structure/mirror-binary-tree-in-data-structure2.png)
- Data structures: Mirror binary trees can be used to efficiently implement data structures such as linked lists and stacks, which have a natural left-to-right ordering.
- Algorithms: Mirror trees can be used to efficiently implement algorithms such as in-order traversal, which involves visiting the nodes of a binary tree in a specific order. In a mirror tree, the in-order traversal is simply the pre-order traversal of the mirror tree.
- Expression evaluation: Mirror trees can also be used to implement efficient algorithms for evaluating expressions represented as binary trees.
- Tree manipulation: Mirror trees can be used to efficiently implement operations such as insertion and deletion in data structures like binary search trees, as the mirror structure allows for quick access to the nodes that need to be modified.
Overall, mirror binary trees can be a useful tool in a variety of contexts where it is necessary to efficiently manipulate or access the data stored in a tree structure.
It is not clear who first invented mirror binary trees or when they were first used. Mirror trees have likely been used in various forms for many years, as they provide a useful way to represent and manipulate data in tree structures. Mirror trees are closely related to other tree data structures such as binary search trees, which are used to efficiently store and retrieve data, and expression trees, and to represent mathematical expressions. Both of these data structures have a long history, and it is likely that mirror trees have been used in some form for many years as well.
It is also possible that mirror trees have been independently discovered and used by different people at different times, as they are a relatively simple and straightforward data structure"