For faster navigation, this Iframe is preloading the Wikiwand page for 2-3-4树.

2-3-4树

此条目没有列出任何参考或来源。 (2015年3月7日)维基百科所有的内容都应该可供查证。请协助补充可靠来源改善这篇条目。无法查证的内容可能会因为异议提出而被移除。
2–3–4树
类型
大O符号表示的时间复杂度
算法 平均 最差
空间
搜索
插入
删除

2-3-4树(英语:2–3–4 tree)在计算机科学中是阶为4的B树

大体同B树,2-3-4树是一种自平衡数据结构,可用于实作字典。它可以在时间内查找、插入和删除,这里的n是树中元素的数目。

2-3-4树在多数编程语言中实现起来相对困难,因为在树上的操作涉及大量特殊情况。红黑树实现起来更简单一些,所以可以用它来替代。

背景

[编辑]

2-3-4树把数据存储在叫做元素的单独单元中。它们组合成节点,每个节点都是下列之一

  • 2-节点,就是说,它包含1个元素和2个子节点,
  • 3-节点,就是说,它包含2个元素和3个子节点,
  • 4-节点,就是说,它包含3个元素和4个子节点。
2-节点
3-节点
4-节点

每个子节点(可能为空)都是一个子2-3-4树。节点是其中没有父亲的那个节点;它在遍历树的时候充当起点,因为从它可以到达所有的其他节点。叶子节点是有至少一个空子节点的节点。

B树一样,2-3-4树是有序的:每个元素必须大于或等于它左边的和它的左子树中的任何其他元素。每个子节点因此成为了由它的左和右元素界定的一个区间

2-3-4树是红黑树的一种等同,这意味着它们是等价的数据结构。换句话说,对于每个2-3-4树,都存在着至少一个数据元素是相同次序的红黑树。在2-3-4树上的插入和删除操作也等价于在红黑树中的颜色翻转和旋转。这使得它成为理解红黑树背后的逻辑的重要工具。

{{bottomLinkPreText}} {{bottomLinkText}}
2-3-4树
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?