P 249 21

advertisement
P249.21. Let T be a complete n- tree with m vertices of which k are non-leaves and l are leaves.
(That is, m=k + l.) Prove that m= k + l and l= (n-1) k+1.
Solution: According to exercise 20, we know that m= kn + 1, where k is the number of non-leaves
and 1 counts the root. Then l= m-k = k(n-1)+1.
P249.25. Let T be a tree. Suppose that T has r vertices and s edges. Find a formula relating r to s.
Solution: Since every vertex except the root has in-degree 1, the sum of all in-degrees of T is
precisely equal to n-1. On the other hand, we notice that each edge contributes exactly 1 to the
sum of all in-degrees of T, i.e., n-1. So s = r -1.
P253.12. How many distinct binary positional trees are there with height 2 ?
Solution: There are C 21 ( C 21 + C 22 ) + C 22 ( C 41 + C 42 + C 43 + C 44 ) = 21distinct binary positional
trees with height 2.
P254.18. Give arrays LEFT, DATA, and RIGHT describing the tree given in Figure 7.12 as a
doubly linked list.
Solution: INDEX
LEFT
DATA
RIGHT
1
2
0
2
3
1
9
3
4
2
6
4
0
4
5
5
0
7
0
6
7
5
0
7
0
8
8
8
0
11
0
9
0
3
10
10
11
6
12
11
0
9
0
12
13
10
0
13
0
12
0
P.262.16. Consider the tree digraph shown in Figure 7.22 and the following list of words. Suppose
that visiting a node of this tree means printing out the word corresponding to the number that
labels that node. Print out the sentence that results from doing a postorder search of the tree.
1. ONE
2. COW
3. SEE
4. NEVER
5. PURPLE
6. NEVER
7. I
8. A
9. I
10. I
11. SAW
12. HOPE
FIGURE 7.22
Solution: The postorder search yields the sequence 7,4,11,8,5,2,9,12,10,6,3,1. So the sentence is: I
NEVER SAW A PURPLE COW I HOPE I NEVER SEE ONE.
P271.20. State your conclusion for Figure 7.48 as a theorem and prove it.
Theorem: There are n spanning trees in the directed circle.
Proof: When we remove one arc from the directed circle, the graph remained has n vertices and
n-1 arcs. So it is a spanning tree. When we remove more than 1 arcs, the graph remained has n
vertices and less than n-1 arcs, and it is not a tree. Hence we can remove exactly one arc to get all
the spanning trees of the directed circle. It is clear that there are n ways to remove the arcs.
Equivalently, there are n spanning trees in the directed circle.
A1
An
A2
A3
P276.20. Give a simple condition on the weights of a graph that will guarantee that there is a
unique maximal spanning tree for the graph.
Solution: The edges of the graph have different weights will guarantee that there is a unique
maximal spanning tree for the graph.
P285.16. Give an example of a graph that is regular, but not complete, with each vertex having
degree three.
Solution:
P286.26. Prove that if a graph G has no loops and multiple edges, then twice the number of edges is
equal to the sum of the degrees of all vertices.
Proof: Since G has no loops and multiple edges, each edge contributes exactly 2 to the total degrees
of the vertices of G, i.e., the sum of the degrees of all vertices. So twice the number of edges
is equal to the sum of the degrees of all vertices
Download