CPSC 212-302 Test #3, Part B April 26, 2006 1. Consider the adjacency matrix of an undirected complete graph. The number of edges is the number of elements in the uppper triangular matrix, namely the number of stars in the diagram below: . * * * * = 1 + 2 + 3 + ... + (n-1) = (n-1)*n/2 . . * * * . . . * * . . . . * . . . . . 2. Dijkstra: (start with node 4) dv pv 0 13 1 1 6 4 2 21 3 3 19 5 4 0 - 5 15 1 3. None of the answers are topological sorts. (a) problem: M before B (b) F before G (c) L before C (d) D before K (e) N before M 4. Huffman Tree: root: 49 Decoded message: s m a r t children of 99: 21 28 children of 21: 10 (e) 11 children of 28: 12 (sp) 16 children of 11: 5 (a) 6 (s) children of 16: 7 9 (t) children of 7: 3 (m) 4 (r) 5. Kruskal's (expected sorted list of edges with check marks and x marks) (0,4) 1 Total Cost = 11 (0,5) 2 (0,2) 2 (2,3) 2 (1,5) 4 6. Prim: (start with node 1) dv pv 0 2 5 1 0 - 2 2 0 3 2 2 4 1 0 5 4 1 7. Depth-first postorder starting with node D Expected evidence of use of stack Traversal: A F I C H B G J E D 8. Breadth-first traversal starting with node G Expected evidence of use of queue Traversal: G B F A C H E D I J 9. Cost of tour = 40 Offspring: 1 2 5 3 7 4 6 0 1 5 3 2 7 0 6 4