# HW5A - 0 1 4371 2 3 1323 4 6173 5 9679 6 7 4344 8 9 4199 No...

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

p.172 5.1 Given input {4371, 1323, 6173, 4199, 4344, 9679, 1989} and a hash function h(X) = X (mod 10), show the resulting: a. Separate chaining hash table. b. Open addressing hash table using linear probing. c. Open addressing hash table using quadratic probing. d. Open addressing hash table with second hash function h 2 (X) = 7 - (X mod 7). Answer h f (4371)=1 h f (1323)=3 h f (6173)=3 h f (4199)=9 h f (4344)=4 h f (9679)=9 h f (1989)=9 TableSize = 10 a. Separate chaining hash table. 0 1 2 3 4 5 6 7 8 9 4371 6173 1323 4344 1989 9679 4199

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

View Full Document
b. Open addressing hash table using linear probing. 0 9679 1 4371 2 1989 3 1323 4 6173 5 4344 6 7 8 9 4199 c. Open addressing hash table using quadratic probing. 0 9679 1 4371 2 3 1323 4 6173 5 4344 6 7 8 1989 9 4199 d. Open addressing hash table with second hash function h 2 (X) = 7 - ( X mod 7 ).

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: 0 1 4371 2 3 1323 4 6173 5 9679 6 7 4344 8 9 4199 No place for 1989 p.172 5.2 Show the result of rehashing the hash tables in Exercise 5.1. Answer The size of new table is 23 , the first prime that is about twice as large as the original table size. The new hash function is then h(X) = X mod 23 . a. Separate chaining hash table. 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1989 9679 4199 4344 6173 1323 4371 b. Open addressing hash table using linear probing. 0 1 4371 2 3 4 5 6 7 8 9 6173 10 11 1989 12 1323 13 4199 14 15 16 17 18 19 9679 20 4344 21 22 23 c. Open addressing hash table using quadratic probing. d. Open addressing hash table with second hash function h 2 (X) = 7 - ( X mod 7 ). Same table obtained as in part a since there is no collision to be resolved....
View Full Document

## This note was uploaded on 02/16/2011 for the course CS 136 taught by Professor Yuechen during the Winter '08 term at Zhejiang University.

### Page1 / 4

HW5A - 0 1 4371 2 3 1323 4 6173 5 9679 6 7 4344 8 9 4199 No...

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

View Full Document
Ask a homework question - tutors are online