

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


COP 4530 Term Exam 4 Name: Fall 2001 SSN: Professor Chris Lacher CS Username: Score: /
This test contains 2 questions (10 subquestions) on 3 pages. Each subquestion is worth 10 points.
unsigned int hash_function (const String& S) { unsigned int hval(0), i; for (i = 0; i < S.Size(); ++i) hval += S[i] - 'a'; return hval; }
Begin with a 5-bucket table t after the operations t.Insert("ab",1); t.Insert("cd",2); t.Insert("ef",3); t.Insert("gh",4); t.Insert("pq",5); have been performed.
a. Illustrate the result of the operation: t.Dump(cout);
b. Illustrate the result of the traversal (I is a table iterator): for (I = t.Begin(); I != t.End(); ++I) cout << *I;
Page 1 of 3 All rights reserved. No part of this exam may be reproduced, stored in a retrieval system, or transmitted in any means without written permission from the publisher or a license from Florida State University. This exam may not be distributed and is the academic property of the Department
hash function vals String value a (^0) b 1 c (^2) d (^3) e f g h i j k l m n o p q r s t u v w x y z
COP 4530 Exam 1 Spring 2001
Now assume that these five additional operations t.Remove("ab"); t.Remove("gh"); t.Insert("ab",6); t.Insert("jk",7); t.Insert("pq",8); have been performed.
c. Illustrate the result of the operation: t.Dump(cout);
d. Illustrate the result of the traversal (I is a table iterator): for (I = t.Begin(); I != t.End(); ++I) cout << *I;
e. Under certain assumptions, a hash table has expected runtime O(1) for its insert, remove, and look-up operations. What are these assumptions?
Page 2 of 3 All rights reserved. No part of this exam may be reproduced, stored in a retrieval system, or transmitted in any means without written permission from the publisher or a license from Florida State University. This exam may not be distributed and is the academic property of the Department