Invert Binary Tree

How to Invert Binary Tree or How to convert a binary tree into its mirror tree.

Given a binary tree, we have to write a code to invert it.

Inverting a Binary Tree

Inverting a binary tree means we have to interchange the left and right children of all non-leaf nodes. In simple words, Output is the mirror of the input tree.

Right View of a Binary Tree

Given a binary tree, we have to write a code to print the right view of a binary tree.

Right View of a Binary Tree

The right view of a binary tree is the set of visible nodes when it is visited or seen from the right side.

For example:

Example 1:

Let’s take an example. In this binary tree, the node which is visible from the right side is 1, 3, 4, and 8.

Binary Tree Inorder Traversal without Recursion using Stack

In this tutorial, I am going to discuss binary tree inorder traversal without recursion.

Given a binary tree, write a code to print the Inorder traversal of a binary tree node values.

What is Binary Tree Inorder Traversal?

Traversing a tree means visiting each node of the tree exactly once. In inorder traversal, we visit the tree in following order.

i) Visit all the nodes of the left subtree.

ii) Visit root node.

iii) Visit all the nodes of the right subtree.