Perfect binary tree in order and pre order automatic indexing

19 views Asked by At

Given a binary tree is a perfect binary tree and the nodes are represented in a numeric way which gives consecutive numbers to each depth from left to right. Can we derive the in order and pre order orders of the trees for all depth? Numeric representation is given as an example for a tree of depth 3. In order is [4, 2, 5, 1, 6, 3, 7] and the pre order is [1, 2, 4, 5, 3, 6, 7]. My question is can we automatically derive this lists by given only depth with a mathematical approach? Perfect Binary Tree

I expect a algorithm that inputs the depth and gives the in order and pre order lists.

0

There are 0 answers