| NAME: Final Exam |
May 16, 1998 Computer Science 226 |
This test is 17 questions, weighted as indicated. Do all of your work on these pages (use the back for scratch space), giving the answer in the space provided. Put your name on every page (now), and write out and sign the Honor Code pledge before turning in the test.
``I pledge my honor that I have not violated the Honor Code during
this examination.''
insert time delete time
worst best average worst best average
BST
Key-Indexed Search
Red-Black Tree
Splay Tree
Separate Chaining
Double Hashing
Patricia Trie
2. (5 points)
Draw the union-find forests for the edges AB BC AD CE DF EG FH GI HJ IK JL KM,
using path compression without weight balancing.
R A N D O M K E Y S
are inserted in that order into an initially empty tree.
R A N D O M K E Y S
are inserted in that order into an initially empty tree.
00010011(in decreasing order of their length, or moving left to right) into an initially empty trie.
arandomstring(in decreasing order of their length, or moving left to right) into an initially empty tree.
000 001 002 003 004 005 006 007 010 011 012 013 014 015 016 017 020in that order into an initially empty tree, with M = 4. Use the style of Figures 16.5 through 16.7 in the book.
000 001 002 003 004 005 006 007 010 011 012 013 014 015 016 017 020in that order into an initially empty table, with M = 4. Use the style of Figures 16.11 through 16.13 in the book.
AB EB AE AC CD GD DC EF FG BC FB.Give the maximum and minimum possible values for the maximum depth of the recursion when this graph is searched with depth-first search, starting at A.
AB(3) EB(1) AE(4) AC(1) CD(5) GD(9) DC(2) EF(6) FG(2) BC(5) FB(3) AH(7)where the numbers in parentheses are edge weights. Give a minimal spanning tree and a shortest path tree from A for the graph.
(0, 3, 2) (1, 2, 5) (0, 1, 1) (3, 0, 2) (4, 3, 1) (4, 0, 2)are inserted in that order into an initially empty tree.
A(3) B(1) C(4) D(1) E(5) F(2) G(6) H(2) I(9)What is the average cost of a search hit in your tree?
void loop(int (*f)(int), int x)
{
a = x, b = f(x);
while (a != b)
{ a = f(a); b = f(f(b)); }
}
Of the following statements, which best describes the behavior of
this function?