Ternary tree with ditstance 4

233 Views Asked by At

Ternary tree is represented by T is tree that has three children except for root. in T3(tree with height 3) how many pair of vertices (u,v) that have distance 4 from each other? (u,v) and (v,u) could be count as 1

enter image description here

attempt: in left subtree $2,5,6,7$, eccentricity of 4 is $3*6=18 + 9=27$ for example $14-5-2-6-17 $

which then total for $\{2,5,6,7\},\{8,3,9,10\},\{11,4,12,13\}$ subtree is $27*3=81$ for subtree including root $\{2,3,4,1\}$ there will be $18+9=27$ so total will be $27*4=108$ is my reasoning right?

1

There are 1 best solutions below

1
On BEST ANSWER

The subtrees with $2,3$ and $4$ as roots each contain $\frac{9\times 6}{2}$ pairs; a total of $81$ pairs.

Now consider pairs of vertices in different subtrees.

Each of the $27$ vertices on the bottom row can be paired with $2$ of the vertices in $\{2,3,4\}$; a total of $54$ pairs.

Each of the $9$ vertices on the next to bottom row can be paired with $6$ of the other vertices in this row; a total of $\frac{9\times 6}{2}=27$ pairs.

The total is confirmed as being $162$.