**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.

## Recommended Posts:

- Remove all leaf nodes from a Generic Tree or N-ary Tree
- Replace every node with depth in N-ary Generic Tree
- Height of a generic tree from parent array
- Generic Linked List in C
- Generic Trees(N-array Trees)
- Convert a Binary Tree to Threaded binary tree | Set 1 (Using Queue)
- Convert a Binary Tree to Threaded binary tree | Set 2 (Efficient)
- Minimum swap required to convert binary tree to binary search tree
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Convert a Binary Tree into its Mirror Tree
- Convert an arbitrary Binary Tree to a tree that holds Children Sum Property
- Convert a given Binary tree to a tree that holds Logical OR property
- Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order
- Convert a given Binary tree to a tree that holds Logical AND property
- Check if a binary tree is subtree of another binary tree | Set 1
- Binary Tree to Binary Search Tree Conversion
- Check if a binary tree is subtree of another binary tree | Set 2
- Check whether a binary tree is a full binary tree or not
- Check whether a given binary tree is skewed binary tree or not?
- Difference between Binary Tree and Binary Search Tree

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.