Create Binary Tree From List
Given Linked List Representation of Complete Binary Tree, construct the Binary tree.
Note : The complete binary tree is represented as an linked list in a way where If root node is stored at position i, its left, and right children are stored at position 2*i+1, 2*i+2 respectively.
- Create tree in post order
index >= list.sizethen,
- Create node with list.get(index)
node.left = Call recursively to create tree with 2 * index + 1
node.right = Call recursively to create tree with 2 * index + 2
Latest Source Code:
List is : [10, 12, 15, 25, 30, 36] Tree is : 10 / \ / \ 12 15 / \ / 25 30 36