With a little more effort, I can express a binary tree — a tree with each node holding a value and exactly two branches. A simple binary tree in Haskell looks like this.
只要多付出一点功夫,就能表达b树——b树的每个节点都容纳一个值和两个分支。
But given you need to use a binary tree, I would store (index, value) in the binary tree and key on index.
但你需要使用一个二进制树,我会把(指数,值)在二树和关键指标。
Given preorder and inorder traversal of a tree, construct the binary tree.
给定一个二叉树的前序和中序遍历,重建这棵二叉树。
应用推荐