Given a Binary Tree (T), Write an algorithm to invert a Binary Tree || Write an algorithm to create a Mirror Image of a Binary Tree (M).
Mirror of a Tree: Mirror of a Binary Tree T is another Binary Tree M(T) with left and right children of all non-leaf nodes interchanged.
Input :
1
/ \
2 3
/. \ / \
4. 5 6. 7
Output:
1
/ \
3 2
/. \ / \
7. 6 5. 4
Code: https://bit.ly/3hsPv5L
[IMPORTANT]
Complete List of interview questions that you need to prepare: https://bit.ly/36AY8Y4
Tree- Interview question and answer:
Part 1: Level Order Traversal of a binary tree (Non-Recursive): /watch/YPyLsZrS1Y2SL
Part 2: Pre Order Traversal of a binary tree (Recursion): /watch/gtrMuyHQkjIQM
#technicalinterview #codinginterview #crackingthetechnicalinterview
Additional Tags:
mirror tree of a given binary tree,
mirror tree problem,
mirror tree code,
mirror tree java,
mirror tree hackerrank,
mirror tree algorithm,
mirror tree bst
invert binary tree python,
invert binary tree iterative,
invert binary tree javascript,
invert binary tree gfg,
invert binary tree in java,
invert binary tree solution,
invert binary tree leetcode,
invert binary tree algorithm,
invert a binary tree,
invert the binary tree,
how to invert binary tree,
how to invert binary tree python,
invert binary tree recursive,
invert the binary tree leetcode,
226. invert binary tree