Question

Construct the tree from the Prüfer code $(5,7,2,2,3,4)$

Original question: (b) Find the tree corresponding to the Prüfer code $(5,7,2,2,3,4)$. Your answer must be the list of edges added to the tree in the order determined by the algorithm (like $[x_1,y_1], [x_2,y_2], ...$). No explanation needed.

Expert Verified Solution

thumb_up100%(1 rated)

Key concept: Going from a Prüfer sequence back to a tree is the reverse of the leaf-removal process. The only thing that matters is staying faithful to the algorithm, especially the order in which edges are created.

Step by step

For the Prüfer code

(5,7,2,2,3,4),(5,7,2,2,3,4),

the corresponding tree has 88 vertices, because a Prüfer code of length 66 comes from a tree on 6+2=86+2=8 vertices.

Using the standard reconstruction algorithm, each step connects the smallest available leaf to the next code entry. The edges are added in this order:

[1,5], [5,7], [6,2], [7,2], [2,3], [3,4], [4,8].[1,5],\ [5,7],\ [6,2],\ [7,2],\ [2,3],\ [3,4],\ [4,8].

So the tree can be described by that edge list.

Pitfall alert

Two classic mistakes show up here: first, forgetting that the tree has n=P+2n=|P|+2 vertices; second, choosing a leaf that is not the smallest available label. That changes the whole tree.

Try different conditions

If the code had repeated numbers in a different pattern, the reconstruction still works the same way. Only the sequence changes; the algorithm does not. If one label were missing from the code entirely, that vertex would usually appear as a leaf in the final tree.

Further reading

Prüfer reconstruction, labeled tree, smallest available leaf

FAQ

How many vertices does a tree with Prüfer code length 6 have?

A Prüfer code of length 6 corresponds to a tree with 8 vertices.

What is the edge list for the tree from the Prüfer code (5,7,2,2,3,4)?

Using the standard reconstruction algorithm, the edges are [1,5], [5,7], [6,2], [7,2], [2,3], [3,4], and [4,8].

chat