2-3-4树中的节点如何拆分有规则吗?
例如,如果我在2-3-4树中插入3,7,4,9:
它会像这样分割(黄色)还是那样(绿色),如下所示:

都是有效的吗?
发布于 2017-02-17 18:40:36
绿色。您需要考虑算法步骤。查看插入步骤的the wikipedia page。关键部分是在考虑下一个插入之前,通过将中间值上移一层来拆分一个4节点(它有3个值)。
1. Insert 3 into blank. Result: 3 (a 2-node)
2. Insert 7. Result: 3 - 7 (a 3-node)
3. Insert 4. Result: 3 - 4 - 7 (a 4-node)
5. Insert 9. There is already a 4-node, so this must be split.
The split will be to move 4 up a level, and 3 and 7 are now child nodes of 4
(like your green diagram). 9 is then added next to the 7.https://stackoverflow.com/questions/42295308
复制相似问题