**Prerequisite:** Generic Trees(N-array Trees)

In this article, we will discuss the conversion of the Generic Tree to a Binary Tree. Following are the rules to convert a Generic(N-array Tree) to Binary Tree:

- The root of the Binary Tree is the Root of the Generic Tree.
- The left child of a node in the Generic Tree is the Left child of that node in the Binary Tree.
- The right sibling of any node in the Generic Tree is the Right child of that node in the Binary Tree.

**Examples:**

Convert the following Generic Tree to Binary Tree:

__Below is the Binary Tree of the above Generic Tree__:

Note:If the parent node has only the right child in the general tree then it becomes the rightmost child node of the last node following the parent node in the binary tree.

In the above example, if nodeBhas the right child nodeLthen in binary tree representationLwould be the right child of nodeD.

Below are the steps for the conversion of Generic Tree to Binary Tree:

- As per the rules mentioned above, the root node of general tree
**A**is the root node of the binary tree. - Now the leftmost child node of the root node in the general tree is
**B**and it is the leftmost child node of the binary tree. - Now as
**B**has**E**as its leftmost child node, so it is its leftmost child node in the binary tree whereas it has**C**as its rightmost sibling node so it is its right child node in the binary tree. - Now
**C**has**F**as its leftmost child node and**D**as its rightmost sibling node, so they are its left and right child node in the binary tree respectively. - Now
**D**has**I**as its leftmost child node which is its left child node in the binary tree but doesn’t have any rightmost sibling node, so doesn’t have any right child in the binary tree. - Now for
**I**,**J**is its rightmost sibling node and so it is its right child node in the binary tree. - Similarly, for
**J**,**K**is its leftmost child node and thus it is its left child node in the binary tree. - Now for
**C**,**F**is its leftmost child node, which has**G**as its rightmost sibling node, which has**H**as its just right sibling node and thus they form their left, right, and right child node respectively.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

**Practice Tags :**