在树形数据结构中,节点是其自身的兄弟节点吗?

发布于 2024-09-27 22:51:38 字数 150 浏览 8 评论 0原文

我正在构建一个类似树的数据结构。 那么预期的行为是什么

public Set getSiblingNodes(Node node);

如果我有一个方法,该方法应该返回一个包含或排除自身的集合,

?谢谢!

I am building a tree like data structure. What is the expected behavior if I have a method

public Set getSiblingNodes(Node node);

Should this method return a set including or excluding itself?

Thanks!

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

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

发布评论

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

评论(2

忆沫 2024-10-04 22:51:38

不。它应该只包含它的兄弟姐妹。
节点不是其自身的兄弟节点
(为什么你会有不同的想法?)

No. It should contain only it's siblings.
A node is not a sibling of itself.
(Why would you think otherwise?)

笑梦风尘 2024-10-04 22:51:38

一般来说没有
但是您可以定义某种树,其中兄弟姐妹构建循环列表,然后如果该列表有一个节点,它将成为其自身的兄弟姐妹。

generally no,
But you can define some sort of tree, where siblings build the circular list and then if this list has one node it will be a sibling of itself.

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