0

I am currently about to implement a multi-way tree in c++, but I am still not sure about what exactly they are. I have read a few documentations, but I am still confused because of the lack of pictures or visualization provided.

Lets say I want a 3 way tree, according to online web notes it means each node can have at most 3-1 = 2 elements and each node can have at most 3 children. Below I have drawn some trees that I am not sure if they are 3-way trees, can someone please verify I am understanding this correctly? Thank you!

Also, if I have a 2 way tree, does that mean I have a binary tree as well? O.o? enter image description here

4

1 回答 1

1

我对多路树的理解是从单个节点可以遍历的子树的数量。

           +---+  
           | D |
           +---+  
             ^  
             |  
             |  
+---+     +------+     +---+  
| A | <-- | Root | --> | B |  
+---+     +------+     +---+
             |  
             |  
             V
           +---+  
           | C |  
           +---+  

上图显示了一个多路树,因为根有多个子节点。

通常每个节点有 2 个子节点(叶节点除外)表示二叉树。
二叉树有很多种。

另请参见 B-Tree 和 B*Trees。

编辑1:
另一种观点:

 +------------------------+  
 |          Root          +
 +------------------------+  
  |       |       |       |  
  V       V       V       V  
+---+   +---+   +---+   +---+  
| A |   | B |   | C |   | D |  
+---+   +---+   +---+   +---+  
于 2015-04-10T00:20:14.050 回答