notes50

# notes50 - CS 251 Collision Handling Techniques by Brad...

This preview shows pages 1–3. Sign up to view the full content.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 251: Collision Handling Techniques - by Brad Prugar Monday, February 13, 2006 15:30 PM 0 maxSize -1 <--key • Example: hash(k) = k mod 7 insert 18 hash(18) = 18 % 7 = 4 0 1 2 3 4 5 6 0 1 2 3 4 5 6 18 insert 41 hash(41) = 41 % 7 = 6 0 1 2 3 4 5 6 18 41 insert 22 hash(22) = 22 % 7 = 1 0 1 2 3 4 5 6 18 41 22 insert 43 hash(43) = 43 % 7 = 1 (in use) Increase probe = 2 0 1 2 3 4 5 6 22 43 18 41 Double Hashing o It is like linear probing but instead of incrementing by 1, the probe is incremented by a value given by a second hash function. double_hash_insert(k, d) { if (table is full) { Return error } probe = hash1(k); offset = hash2(k); while (table[probe] is in use) { probe = (probe + offset) % MaxSize;...
View Full Document

{[ snackBarMessage ]}

### Page1 / 6

notes50 - CS 251 Collision Handling Techniques by Brad...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online