Вы находитесь на странице: 1из 13

CS291: Quiz1 Review 2010

1. For the following graph tell whether the given path is a) A simple path b) A cycle c) A simple cycle d) None of the above

e9 A e2 e1 e3 e5 B e4 C

e6 D e7
(a) (A,e2,E,e3,B,e4,C,e5,F,e8,E,e6,D,e1,A). (b) (B,e3,E,e3,B,e4,C,e5,F). (c) Does the graph above have an Euler Cycle? If so, show it. If not, show why not. (d) Does the graph above have an Euler Path? If so, show it. If not, show why not. (e) Does the graph above have a Hamiltonian Cycle? If so, show it. If not, show why not.

e8

Please turn page

2. (20 points) For the following graph G, use Dijkstras algorithm to nd the shortest path from a to z. You must show all steps (iterations) starting with all temporary labels equal to . And clearly showing which labels become permanent at each iteration and which nodes get temporary labels at each iteration.

B 1 A 2 3 F 2

C 4 4

D 2

2 E 1 2

Z 5

Please turn page

Iter. 0 1 2 3 4 5 6 7 8 9 10 11 12

a T,0

b T,

c d e T, T, T,

f g z T, T, T,

Please turn page

3. For the following adjacency matrix do the following: v1 A = v2 v3 v4 (a) Show the graph. (b) Show the incidence matrix. (c) Show all paths of length 2. v1 v2 v3 v4 2 1 1 1 1 0 0 2 1 0 0 1 1 2 1 0

Please turn page

4. Are the following graphs Isomorphic? If so, show a mapping. If not, show that they are not using an invariant.

B 1 A C 5 3 D E 4 2

Please turn page

5. Is the following graph planar? If so, draw it. If not, use Kuratowskis theorem to show that it is not.

Please turn page

6.

(a) Construct an optimal Human code for the set of letters in the following table: (Write out the binary Human code for each letter)

Character A B C D E F

Frequency 5 8 5 12 20 10

(b) What is the average length of this Human code? (c) What is the length of a binary representation of the letters? (d) For a Human code consisting of n symbols, what is the maximum height h of the binary tree? (e) For a Human code consisting of n symbols, what is the minimum height h of the binary tree?

Please turn the page

7.

(a) Use depth rst search to nd a spanning tree for the following graph with the following vertex ordering: abcdefghi (b) Use breadth rst search to nd a spanning tree for the following graph with the following vertex ordering: abcdefghi

Please turn the page

8.

(a) Use Prims algorithm to nd a minimal spanning tree for the following graph. Clearly label the order in which each edge is added to the tree. (b) Use Kruskals algorithm to nd a minimal spanning tree for the following graph. Clearly label the order in which each edge is added to the tree.

14

24 2 6

26

12

18

28

16

30

22

g
10

h
20

Please turn the page

9.

(a) PLACE THESE NINE WORDS INTO A BINARY SEARCH TREE (in the order they appear) (b) A full binary search tree has 430 elements. Exactly how many comparisons are needed to search for an element in the worst case? (c) Represent the prex expression -*E/BD-CA as a binary tree (d) Write the postx form. (e) Write the fully parenthesized inx form of the above expression.

Please turn the page

10.

(a) Find the value of the following position in tic-tac-toe using the following evaluation function E(P ) = N X N O, where N X is the number of rows, columns, or diagonals that X can complete, and N O is the number of rows, columns, or diagonals that O can complete.

X O X O
(b) Evaluate the root of the following game tree using depth-rst search and alpha-beta pruning working from left to right. Label each alpha and beta cuto

12

10

Please turn page

11. Five students; Ben, Cathy, David, Eitan, and Zhefu are competing for 5 class awards: most ambitious, best at cooking, best at golf, best at chess, and class clown. Ben has been nominated for best at cooking, best at golf, and best at chess. Cathy has been nominated for most ambitious and class clown. David has been nominated for best at cooking, best at golf, and best at chess. Eitan has been nominated for most ambitious and class clown and Zhefu is nominated for most ambitious. Only one nominee in each category will receive an award. The awards committee needs to know how many awards they need to order. (a) (5 points) Model this situation as a matching network. (b) (5 points) Is there a complete matching? If not, use Halls marriage theorem to prove there is no complete matching. (c) (5 points) Find a minimal cut in the matching network. (d) (5 points) Show a maximal matching.

Please turn page

12. Answer the following questions for the network depicted below. (a) What is the capacity of the cut shown in the network? (b) Is this a minimal capacity cut? (c) If not a minimal capacity cut, show one. (d) Show a maximum ow in the network.

5 3 4 1 1 6 5 5 3

Вам также может понравиться