从树的节点获取信息

发布于 2024-09-02 08:11:29 字数 223 浏览 8 评论 0原文

我正在使用树数据结构,并试图想出一种方法来计算可以从树的节点获得的信息。

我想知道是否有任何现有技术可以为在较低级别(距树根的距离)出现频率较低的节点分配比在较高级别和高频出现的相同节点更高的数值重要性。

举个例子,我想赋予节点Book更多的意义,在2级出现一次, 然后在3级出现三次。

将不胜感激任何实现类似目标的技术建议/指针。

谢谢,

普拉泰克

I am working with the tree data structure and trying to come up with a way to calculate information I can gain from the nodes of the tree.

I am wondering if there are any existing techniques which can assign higher numerical importance to a node which appears less frequently at lower level (Distance from the root of the tree) than the same nodes appearance at higher level and high frequency.

To give an example, I want to give more significance to node Book, at level 2 appearing once,
then at level 3 appearing thrice.

Will appreciate any suggestions/pointers to techniques which achieve something similar.

Thanks,

Prateek

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

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

发布评论

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

评论(2

通知家属抬走 2024-09-09 08:11:29

我刚刚想到的一个指标是:对于标签k,让它的“值”是它出现的级别的总和。因此,如果它出现在根和根的左子节点上,则将其值设置为 1。

然后,最“重要”的标签就是那些具有最低值的标签。

编辑:这将使根比其子级的标签更重要,即使它们都是相同的。因此,按出现次数进行一些缩放可能是合适的。

One metric I just thought of is this: for a labelk, let it's "value" be the sum of the levels it appears at. So, if it appears at the root and the root's left child, let it's value be 1.

Then, your most "important" labels are those with the lowest value.

EDIT: This will make the root more important than the label of it's children, even if they are both the same. So, some scaling by occurrence count might be in order.

围归者 2024-09-09 08:11:29

这取决于你想在每个级别赋予它多少重要性。

只需乘以一个数字,该数字会随着树的层级向下移动而减小。例如,n_nodes * 1/(3^n),其中 n 是树的级别。因此,第 2 层上的一个节点的值为 1/4,第 3 层上的 3 个节点的值为 1/9。因此,第 2 层的单个节点更为重要。

根据您的喜好调整分母。只要它随着 n 的增加,就会赋予树中较高的节点更重要的意义。

It depends how much significance you want to give to it at each level.

Just multiply by a number that decreases as you move down the levels of the tree. For example, n_nodes * 1/(3^n), where n is the level of the tree. Thus, a node on level 2 gets a value of 1/4, and 3 nodes on level 3 get a value of 1/9. Thus, the single node on level 2 is more significant.

Adjust the denominator to your liking. As long as it increases with n, it will give more significance to nodes higher in the tree.

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