Left-Child Right-Sibling Representation is a different representation of an n-ary tree where instead of holding a reference to each and every child node, a node holds just two references, first a reference to it’s first child, and the other to it’s immediate next sibling. This new transformation not only removes the need of advance knowledge of the number of children a node has, but also limits the number of references to a maximum of two, thereby making it so much easier to code.
At each node, link children of same parent from left to right. Parent should be linked with only first child.
Left Child Right Sibling tree representation 10 | 2 -> 3 -> 4 -> 5 | | 6 7 -> 8 -> 9
Prerequisite : Left-Child Right-Sibling Representation of Tree
Below is the implementation.
10 2 3 4 6 5 7 8 9
This article is contributed by SAKSHI TIWARI. If you like GeeksforGeeks(We know you do!) and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Left-Child Right-Sibling Representation of Tree
- Convert left-right representation of a binary tree to down-right
- Construct Binary Tree from given Parent Array representation
- Construct Binary Tree from String with bracket representation
- Shortest path between two nodes in array like representation of binary tree
- Construct Complete Binary Tree from its Linked List Representation
- SQL | Creating Roles
- Creating a PortScanner in C
- Creating a file using FileOutputStream
- PHP | MySQL ( Creating Table )
- PHP | MySQL ( Creating Database )
- Python | Creating a 3D List
- Android | Creating a RatingBar
- Android | Creating a Splash Screen
Improved By : MvssTeja