We can number binary trees using the following scheme:
The empty tree is numbered 0.
The single-node tree is numbered 1.
All binary trees having m nodes have numbers less than all those having m+1 nodes.
Any binary tree having m nodes with left and right subtrees L and R is numbered n such that all trees having m nodes numbered > n have either Left subtrees numbered higher than L, or A left subtree = L and a right subtree numbered higher than R.
The first 10 binary trees and tree number 20 in this sequence are shown below:
Your job for this problem is to output a binary tree when given its order number.
我们可以使用以下方案对二叉树进行编号:
空树编号为 0。
单节点树编号为 1。
所有具有 m 个节点的二叉树的数量都小于所有具有 m+1 个节点的二叉树。
任何具有 m 个节点且具有左子树和右子树 L 和 R 的二叉树都被编号为 n,使得所有具有 m 个节点编号 > n 的树都具有编号高于 L 的左子树,或者一个左子树 = L 和一个编号高于 R 的右子树 .
该序列中的前 10 棵二叉树和第 20 棵树如下所示:
你要解决的问题就是再给定序号输出二叉树