这是什么样的对象树?

发布于 2024-09-08 00:56:46 字数 246 浏览 1 评论 0原文

我需要创建一棵树,由可能具有任意数量(在合理范围内,例如 0 到 10 之间)的传出转换的节点构成,如下所示:

               X 
             / | \
            X  X  X
           /
          X
         / \
        X   X

这是什么类型的树结构?有什么技术可以构建和专门修改这种树?

谢谢

I need to create a tree, constructed of nodes that may have any number (within reason, between 0 and 10 say) of outgoing transitions, like so:

               X 
             / | \
            X  X  X
           /
          X
         / \
        X   X

What sort of tree structure is this? What techniques are there for constructing and specifically modifying trees of this kind?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

柏林苍穹下 2024-09-15 00:56:46

这只是一棵通用树。也许因为二叉树太常见了,这棵树看起来不同,但实际上,它是二叉树,是树的一种特殊情况。

您不需要任何特殊技术来处理一棵树。如果您习惯二叉树,您可能会使用左指针和右指针来保存子树。在这种情况下,正如您所说,如果您想要 0 到 10 个子级,您可以将 left/right 替换为包含 10 个指针的数组。

This is just a generic tree. Maybe because binary trees are so common, this tree looks different, but in fact, it is the binary tree that is a special case of a tree.

You don't need any special techniques to handle a tree. If you're used to binary trees, you probably use a left and right pointer to hold the children. In this case, as you say, if you want between 0 and 10 children, you would replace left/right with an array of 10 pointers.

鹊巢 2024-09-15 00:56:46

这是一棵树,纯粹而简单。它只是不是一个二叉树(每个节点最多有 2 个子节点)。大多数树结构都应该能够处理它。

It's a tree, pure and simple. It's just not a binary tree (which has a maximum of 2 children per node). Most any tree structure should be able to handle it.

浮光之海 2024-09-15 00:56:46

听起来像是 2-3 树 的一种形式,但事实并非如此2 个数据条目,3 个到其他节点的链接,您可以根据需要扩展它。

Sounds like a form of the 2-3 tree, but it hasn't to be 2 data entrys with 3 links to other nodes, you can expand it as you like.

夏の忆 2024-09-15 00:56:46

仅从提供的信息来看,这棵树不属于任何特殊类别。我想您正在沿着二叉树的思路思考,但是一旦您获得的节点的子节点数不是 2 或 0,就没有特殊的分类。

根据它的具体实现和使用方式,它可能是也可能不是有序树:有序树节点以明确的有意顺序而不是任意顺序存储其子节点。

如果它是一棵有序树(或至少被实现为一棵有序树),则任何给定节点都可以表示为一系列数字,指示从基节点开始的节点到子节点的移动序列。例如,

0, 0, 1

将表示基本节点最左边子节点的唯一子节点的右子节点。以这种方式存储对节点的引用可以简化很多事情,并且编写一个简单的函数来迭代这样的序列并返回结果节点非常容易。

From the information provided alone, this tree does not fall into any special category. I imagine that you're thinking along the lines of binary trees, but once you get nodes with a number of children other than 2 or 0, there's no special classification.

Depending on how exactly it's implemented and used, it may or may not be an ordered tree: ordered tree nodes store their children with an explicit intentional order rather than in an arbitrary order.

If it is an ordered tree (or at least is implemented as one), any given node can be expressed as a series of numbers indicating a sequence of node-to-child movements, starting at the base node. For example,

0, 0, 1

would represent the right child of the sole child of the left-most child of the base node. Storing references to nodes in this way can simplify a lot of things, and it's pretty easy to write a simple function to iterate through such a series and return the resulting node.

国产ˉ祖宗 2024-09-15 00:56:46

你所拥有的只是一棵普通的树。特殊情况是二叉树或平衡树。两者都不是。

大多数语言都有用于操作这些的库。递归是一种流行的技术。所有大学级别的数据结构教科书都会深入探讨如何对树进行 CRUD。

您可以此处获取概述

What you have is just a plain tree. Special cases are binary trees or balanced tree. It is neither.

There are libraries in most languages for manipulating these. Recursion is a popular technique. All College level textbooks on Data Structures will go in depth on how to CRUD the tree.

You can get an overview here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文