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 email@example.com. 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.
- Convert left-right representation of a binary tree to down-right
- Left-Child Right-Sibling Representation of Tree
- Construct Binary Tree from given Parent Array representation
- Construct Binary Tree from String with bracket representation
- Construct Complete Binary Tree from its Linked List Representation
- Shortest path between two nodes in array like representation of binary tree
- Construct Binary Tree from given Parent Array representation | Iterative Approach
- Lowest Common Ancestor in Parent Array Representation
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Print Binary Tree levels in sorted order | Set 3 (Tree given as array)
- Convert an arbitrary Binary Tree to a tree that holds Children Sum Property
- Given level order traversal of a Binary Tree, check if the Tree is a Min-Heap
- Check if a given Binary Tree is height balanced like a Red-Black Tree
- Check whether a binary tree is a complete tree or not | Set 2 (Recursive Solution)