非二叉树可以按顺序遍历吗?
我们在这里处理最相似的邻居算法。该算法的一部分涉及按顺序搜索树。
问题是,到目前为止,我们还无法使该树成为二叉树。
是否有类似于非二叉树的顺序遍历。特别是,我认为有,只需从左到右遍历节点(并且仅处理父节点一次?”)
更新
这棵树将在每个节点中都有一个包含 n 个对象的小图。每个节点将有 n 个子节点(每个节点 1 个)图中的每个元素),每个都将是另一个图。所以它的“某种”ab 树,没有所有溢出 - 下溢机制所以我猜最相似的顺序遍历将类似于 btree 中序遍历?
We are dealing with a Most similar neighbour algorithm here. Part of the algorithm involves searching in order over a tree.
The thing is that until now, we can't make that tree to be binary.
Is there an analog to in order traversal for non-binary trees. Particularly, I think there is, just traversing the nodes from left to right (and processing the parent node only once?")
Update
This tree will have in each node a small graph of n objects. Each node will have n children (1 per each element in the graph), each of which will be another graph. So its "kind of" a b tree, without all the overflow - underflow mechanics. So I guess the most similar in order traversal would be similar to a btree inorder traversal ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,但您需要定义顺序是什么。后序和前序是相同的,但中序定义了分支与节点的比较方式。
Yes, but you need to define what the order is. Post and Pre order are identical, but inorder takes a definition of how the branches compare with the nodes.
除了二叉树之外,没有其他树的有序序列的简单模拟(实际上有序是从二叉搜索树中获取排序元素的一种方法)。
您可以在高德纳 (Knuth) 的《计算机编程艺术》第一卷中找到更多详细信息。 1,第 336 页。
如果广度优先搜索可以满足您的目的,那么您可以使用它。
There is no simple analog of the in-order sequence for trees other than binary trees (actually in-order is a way to get sorted elements from a binary search tree).
You can find more detail in "The art of computer programming" by Knuth, vol. 1, page 336.
If breadth-first search can serve your purpose then you can use that.