prufer coding Study Notes

prufer coding

For a rootless tree, his prufer coding is determined by:

  • Each find the smallest number of a leaf node, i.e. the degree of \ (1 \) nodes, the points connected to it , added prufer end of the coding sequence, and deleted from this point the tree
  • If the current tree only two nodes, and stops

Then, through a given request prufer coding unrooted trees very simple
example, the following unrooted trees, it is encoded prufer \ (\ texttt {125214} \ )

This obviously has some prufer encoding properties
first length must be \ (2-n-\) , but each element may be the same , then for each unrooted trees, it certainly unique coding prufer
if each element are encoded the same, then it can be a maximum number of points connected to all other points (special drawing chrysanthemum), if different, can be a chain
of course, here to say "may" because there may be other manner of construction

So, prufer corresponding code tree is unique?
In other words, each code is not only determined only tree?
Is possible, seeking to give way:
set the set point of the tree is \ (V \) , the initial state \ (V = \ {1,2, \ cdots, n \} \)

  • Each time a foremost point code found in \ (V \) Locate not appear in the coding sequence numbering minimum point, even sides, respectively, and then put them in \ (V \) Deletion of the coding and
  • Obviously, when all the codes are deleted, \ (V \) there are two elements, then the two of them even edges and ends

Just then verify that figure, I found to be correct

Sensibility can understand it, the first number of the coding sequence, is the first time we remove its neighboring nodes added after the leaf node, and this is certainly not deleted node coding, it is also the smallest number, so the reduction tree when he put it and its neighbor that is added to the encoding side even point
then every time to do so would come to the original tree
and because when looking for coding the last remaining two nodes, those two nodes must be connected together, so that's why should \ (V \) in the remaining two sides even point

Therefore, the above operation required by prufer coding tree, the only


It can be drawn about the deeper nature:

  • prufer coding and unrooted trees correspondence
  • For \ (n-\) nodes unrooted trees , there \ (n ^ {n-2 } \) species configured manner
    as the coding tree and correspondence, so the length \ (2-n-\) , each bit \ (n-\) number of types of seed values is encoded \ (n-2-n-^ {} \) , this thing is called Cayley formula
  • For \ (n-\) nodes in a rooted tree with \ (n ^ {n-1 } \) species configuration mode, obviously, is to allow each node in turn as the root, then using the equation above
  • Of degree \ (K \) dots, the number of occurrences in the encoding is prufer \ (k-1 \)
    as the \ (k-1 \) points are deleted when it is added to encoded, this degree It is \ (1 \) , added directly deleted without coding
  • For a given \ (n-\) degrees points are \ (k_1, k_2, \ cdots , k_n \) rooted tree, there are \ (\ dfrac {(n- 2)!} {\ Prod (k_i- 1)!} \) species configuration mode
    problem is the demand of each element appears \ (K_i \) the number of times the arrangement, molecule \ ((n-2)! \) is, this restriction is not full array number, go back on the denominator, that is to say if the exchange location like elements should be considered a solution, so that it is divided by factorial
  • The above properties again extended, assuming that there are \ (CNT \) points to the degree required, the other did not request, set \ (SUM = \ sum_ {I =. 1} ^ {CNT} K_i \) , the methods are:
    \ (\ tbinom {n-2 } {sum} \ frac {sum!} {\ prod_ {i = 1} ^ {cnt} (k_i-1)!} \ times (n-cnt) ^ {n-2- sum} \)
    to explain what is meant is that the number of combinations from \ (n-2 \) is calculated which number \ (SUM \) a, and this \ (SUM \) a nature to spend a formula, and further there \ (n-2-sum \ ) position may be arbitrarily arranged in the remaining \ (n-cnt \) points, so the above formulas obtained

It should not, and if there are other properties welcome given Gangster know in the comments area

Then there are problems, such solutions have problems in the classification tulun-prufer encoded
P4430 monkey fighting
P4981 Sons
P2290 [HNOI2004] counting tree
P2624 [HNOI2008] clearly troubles

Guess you like

Origin www.cnblogs.com/suxxsfe/p/12641578.html