In a ternary tree, the number of internal nodes of degree 1,2 and 3 is 4,3 and 3 respectively. The number of leaf nodes in the ternary tree is
10
This problem asks us to find the number of leaf nodes in a ternary tree, given information about its internal nodes based on their degrees.
Before diving into the calculation, let's clarify some terms related to trees:
We are told the number of internal nodes for each specific degree:
Our goal is to determine the total number of leaf nodes in this ternary tree.
In any rooted tree, there is a useful relationship between the number of internal nodes and the number of leaf nodes. For a rooted tree where each internal node \( i \) has \( \text{degree}_i \) children, the number of leaf nodes \( L \) can be found using the formula:
\[ L = 1 + \sum_{\text{all internal nodes } i} (\text{degree}_i - 1) \]This formula sums the quantity \( (\text{degree}_i - 1) \) for every internal node and adds 1 (representing the contribution from the root which doesn't have a parent edge contributing to node count from above).
Let's calculate the sum \( \sum (\text{degree}_i - 1) \) based on the given internal node counts:
Now, we sum these contributions for all internal nodes:
\[ \sum (\text{degree}_i - 1) = 0 + 3 + 6 = 9 \]Now, we plug this sum into the formula for the number of leaf nodes \( L \):
\[ L = 1 + \sum (\text{degree}_i - 1) \] \[ L = 1 + 9 \] \[ L = 10 \]So, the number of leaf nodes in the ternary tree is 10.
Alternatively, we can use the fact that in any tree, the number of edges \( E \) is \( N - 1 \), where \( N \) is the total number of nodes. Also, in a rooted tree, the total number of edges is equal to the sum of the degrees (number of children) of all internal nodes.
Total number of internal nodes \( I = 4 + 3 + 3 = 10 \).
Total number of children = Sum of degrees of internal nodes
\[ \text{Total children} = (4 \times 1) + (3 \times 2) + (3 \times 3) = 4 + 6 + 9 = 19 \]Since the total number of children equals the number of edges in a rooted tree (as each edge connects a parent to a child), we have:
\[ E = 19 \]Using the relation \( E = N - 1 \):
\[ 19 = N - 1 \] \[ N = 19 + 1 = 20 \]The total number of nodes \( N \) is the sum of internal nodes (\( I \)) and leaf nodes (\( L \)).
\[ N = I + L \] \[ 20 = 10 + L \] \[ L = 20 - 10 = 10 \]Both methods yield the same result.
The number of leaf nodes in the ternary tree is 10.
| Node Type | Degree (Number of Children) | Count | Calculation Contribution (\( \text{degree} - 1 \)) |
|---|---|---|---|
| Internal | 1 | 4 | \( 4 \times (1-1) = 0 \) |
| Internal | 2 | 3 | \( 3 \times (2-1) = 3 \) |
| Internal | 3 | 3 | \( 3 \times (3-1) = 6 \) |
| Total Internal Nodes | 10 | Sum \( = 9 \) | |
| Leaf | 0 | 10 (Calculated) | |
| Total Nodes (Internal + Leaf) | 20 |
Rooted trees have several fundamental properties: