{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Hashing-Practice - 15-121 Introduction to Data Structures...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
15-121: Introduction to Data Structures Fall 2009 Exercise 10/15/2009 Hashing Practice Due: none Relevant Reading: Chapter 14 in the Lewis and Chase book. Assignment: (worth 0 exercise points - this is for practice only) Consider the following potential hashCode functions for Strings. public int hashCode() { if (length() == 0) return 1; return length() + UnicodeValueOf (charAt(0)); } public int hashCode() { int sum = 0; for (int i = 0; i < length(); i++) sum += i * UnicodeValueOf (charAt(i)); return sum; } Below is a list of words. Insert the list of words IN ORDER, one at a time into a hash table. Use both functions, two different table sizes (10 and 25) and both chaining (another word for bucketing) and probing. Thus, you need to create 8 tables. HashCode function on the left, Chaining for collisions, 10 cells in the array. HashCode function on the left, Chaining for collisions, 25 cells in the array. HashCode function on the left, linear probing for collisions, 10 cells in the array.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}