平衡二叉搜索树,存储数据只在叶只在、数据

2023-09-11 03:47:26 作者:心已荒芜

我买了一个可爱的小本关于几何计算,虽然这里阅读它,在那里我经常绊倒在使用这些特殊的二叉搜索树。这些树是平衡的,应当存放只在假期节点的数据,内部节点只能存储值向下引导搜索的叶子。

图片显示了一个例子树,其中叶子是矩形和内部节点是圆

我有两个问题有关:

什么是不存储数据的内部节点的优势在哪里? 对于学习的目的,我想实现这样的树,所以我想这可能是使用AVL树的基础是一个好主意,但果真如此吗?

最后但并非最不重要的我要强调的是,我用的东西打交道,因为我想学的东西,事实让每一种有用的资源是非常欢迎的。由于在未来,问候......

解决方案 有一些树数据结构,通过设计,要求没有数据被存储在内部节点,例如霍夫曼code树和 B +树的。在哈夫曼树的情况下,要求是没有两片叶子具有相同的preFIX(即路径节点'A'是101,而路径节点'B'是10)。在B +树的情况下,它来自于一个事实,这是块搜索优化(这也意味着每一个内部节点有很多的孩子,那树通常只有几个层次深)。 当然! AVL树是不是非常复杂的,所以这是一个很好的候选人学习。

希望这有助于。

I have bought a nice little book about computational geometry and while reading it here and there I often stumbled over the use of these special kind of binary search tree. These trees are balanced and should store the data only in the leave nodes, inner nodes should only store values to guide the search down to the leaves.

优化MySQL的理论基础是什么

The image shows an example tree, where the leaves are rectangles and the inner nodes are circles.

I have two Questions about that:

What is the advantage of not storing data in the inner nodes? For the purpose of learning I would like to implement such a tree, therefore I thought it might be a good idea to use an AVL tree as basis, but is it?

Last but not least I want to underline the fact that I am dealing with that stuff because I want to learn something, so every kind of helpful resource is very welcome. Thanks in ahead, regards....

解决方案

there are some tree data structures that, by design, require that no data is stored in the inner nodes, such as Huffman code trees and B+ trees. In the case of Huffman trees, the requirement is that no two leaves have the same prefix (i.e. the path to node 'A' is 101 whereas the path to node 'B' is 10). In the case of B+ trees it comes from the fact that it is optimized for block-search (this also means that every internal node has a lot of children, and that the tree is usually only a few levels deep). Sure! An AVL tree is not extremely complicated, so it's a good candidate for learning.

Hope this helps.