2

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

4

2 に答える 2

1

私が今考えたメトリックの1つは、これです。ラベルkの場合、「値」を表示されるレベルの合計とします。したがって、ルートとルートの左の子に表示される場合は、値を1とします。

次に、最も「重要な」ラベルは、値が最も低いラベルです。

編集:これにより、子が同じであっても、子のラベルよりもルートの方が重要になります。したがって、発生回数によるスケーリングが適切である可能性があります。

于 2010-05-20T01:32:56.197 に答える
1

それはあなたが各レベルでそれにどれだけの重要性を与えたいかによります。

ツリーのレベルを下に移動するにつれて減少する数を掛けるだけです。たとえばn_nodes * 1/(3^n)、ここで、nはツリーのレベルです。したがって、レベル2のノードは1/4の値を取得し、レベル3の3つのノードは1/9の値を取得します。したがって、レベル2の単一ノードはより重要です。

分母をお好みに合わせて調整してください。nとともに増加する限り、ツリーの上位のノードにより多くの重要性を与えます。

于 2010-05-20T01:47:41.917 に答える