Question

Given input { 66, 28, 43, 29, 44, 69, 19 } and a hash function h(x)...

Given input { 66, 28, 43, 29, 44, 69, 19 } and a hash function h(x) = x mod 10, show the resulting hash table:

1) Using Separate Chaining

2) Using Linear Probing

3) Using Quadratic Probing

0 0
Add a comment Improve this question Transcribed image text
Answer #1
1)
Inserting 66
66 is inserted at position 6
Inserting 28
28 is inserted at position 8
Inserting 43
43 is inserted at position 3
Inserting 29
29 is inserted at position 9
Inserting 44
44 is inserted at position 4
Inserting 69
69 is inserted at position 9
Inserting 19
19 is inserted at position 9
HashTable
-----------
0   -
1   -
2   -
3   -      43
4   -      44
5   -
6   -      66
7   -
8   -      28
9   -      29 -> 69 -> 19

2)
Inserting 66
66 mod 10 = 6
66 is inserted at position 6

Inserting 28
28 mod 10 = 8
28 is inserted at position 8

Inserting 43
43 mod 10 = 3
43 is inserted at position 3

Inserting 29
29 mod 10 = 9
29 is inserted at position 9

Inserting 44
44 mod 10 = 4
44 is inserted at position 4

Inserting 69
69 mod 10 = 9
There is already an item in 9
So, checking at index 0
69 is inserted at position 0

Inserting 19
19 mod 10 = 9
There is already an item in 9
So, checking at index 0
There is already an item in 0
So, checking at index 1
19 is inserted at position 1

HashTable
-----------
0   -      69
1   -      19
2   -
3   -      43
4   -      44
5   -
6   -      66
7   -
8   -      28
9   -      29

3)
Inserting 66
66 is inserted at position 6

Inserting 28
28 is inserted at position 8

Inserting 43
43 is inserted at position 3

Inserting 29
29 is inserted at position 9

Inserting 44
44 is inserted at position 4

Inserting 69
There is already an item in 9
So, checking at index 0
69 is inserted at position 0

Inserting 19
There is already an item in 9
So, checking at index 0
There is already an item in 0
So, checking at index 3
There is already an item in 3
So, checking at index 8
There is already an item in 8
So, checking at index 5
19 is inserted at position 5

HashTable
-----------
0   -      69
1   -     
2   -     
3   -      43
4   -      44
5   -      19
6   -      66
7   -     
8   -      28
9   -      29
Add a comment
Know the answer?
Add Answer to:
Given input { 66, 28, 43, 29, 44, 69, 19 } and a hash function h(x)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ^b Given input( 66, 28, 43, 29, 44, 69, 19) and a hash function h(x) =...

    ^b Given input( 66, 28, 43, 29, 44, 69, 19) and a hash function h(x) = x mod 10, show the resulting hash table 1) Using Separate Chaining 2) Using Linear Probing 3) Using Quadratic Probing 4) Starting with the following hash function: h2(x) 7- (x mod 7), applv Rehash ary course slides ing as described in the prim Rehashing Increases the size of the hash table when load factor becomes "too high" (defined by a cutoff) - Anticipating that...

  • Given input {4371, 1323, 6173, 4199, 4344, 9679, 1989} and a hash function h(x) = x...

    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. Hash table using linear probing c. Hash table using quadratic probing d. Hash table with second hash function h2(x) = 7 - (x mod 7) *Assume the table size is 10.

  • Given the input of (2341,4234, 2839, 430, 22, 397, 3920;, and a fixed table size of...

    Given the input of (2341,4234, 2839, 430, 22, 397, 3920;, and a fixed table size of 7, and a hash-function h1(x)-x mod 7, show the resulting a. Separate chaining hash-table b. Linear probing hash-table. c. Quadratic probing hash-table. d. Hash Table with second hash function h2(x)- (2x - 1) mod 7

  • 6. Given the input { 4, 42, 39, 18, 77, 97, 7 }, a fixed table...

    6. Given the input { 4, 42, 39, 18, 77, 97, 7 }, a fixed table size of 10 and a hash function H( x ) = x modulo 10, show the resulting hashtable. Index Linear Probing Hashtable Quadratic Probing Hashtable Separate Chaining Hashtable 0 1 2 3 4 5 6 7 8 9

  • 3. Given input (89, 18, 49, 58, 69), h)k(mod 10) g) Iymod 8), and a hash function f(k) h(k) +j-g(...

    3. Given input (89, 18, 49, 58, 69), h)k(mod 10) g) Iymod 8), and a hash function f(k) h(k) +j-g(k) (mod 10), show the resulting hash table. Solve collisions with double hashing. 3. Given input (89, 18, 49, 58, 69), h)k(mod 10) g) Iymod 8), and a hash function f(k) h(k) +j-g(k) (mod 10), show the resulting hash table. Solve collisions with double hashing.

  • 5. Hashing (a) Consider a hash table with separate chaining of size M = 5 and...

    5. Hashing (a) Consider a hash table with separate chaining of size M = 5 and the hash function h(x) = x mod 5. i. (1) Pick 8 random numbers in the range of 10 to 99 and write the numbers in the picked sequence. Marks will only be given for proper random numbers (e.g., 11, 12, 13, 14 ... or 10, 20, 30, 40, .. are not acceptable random sequences). ii. (2) Draw a sketch of the hash table...

  • Suppose we use the hash function h(x) = x mod 7 (i.e. h(x) is the remainder...

    Suppose we use the hash function h(x) = x mod 7 (i.e. h(x) is the remainder of the division of x by 7) to hash into a table with 7 slots (the slots are numbered 0, 1,…, 6) the following numbers: 32, 57, 43, 20, 28, 67, 41, 62, 91, 54. We use chaining to handle collisions. Which slot contains the longest chain?

  • Let 'M' denote the hash table size. Consider the following four different hash table implementations: a....

    Let 'M' denote the hash table size. Consider the following four different hash table implementations: a. Implementation (I) uses chaining, and the hash function is hash(x)x mod M. Assume that this implementation maintains a sorted list of the elements (from biggest to smallest) for each chain. b. Implementation (II) uses open addressing by Linear probing, and the hash function is ht(x) - (hash(x) + f(i)) mod M, where hash(x)x mod M, and f(i)- c. Implementation (III) uses open addressing by...

  • 3. Assume that you have a seven-slot hash table (the slots are numbered 0 through 6)....

    3. Assume that you have a seven-slot hash table (the slots are numbered 0 through 6). Show the final hash table that would result if you used the following approach to put 7, 13, 10,6 into the hash (4 points each) the hash function h(k)-k mod 7 and linear probing function the hash function h(k)-k mod 7 and quadratic probing (a) (b)

  • Given the input sequence 4371, 1323, 6173, 4199, 4344, 9679, 1989, a hash table of size...

    Given the input sequence 4371, 1323, 6173, 4199, 4344, 9679, 1989, a hash table of size b=10, and a hash function h(x)=x mod b, show each step needed to build a hash table A closed hash table using double hashing, with the second hash function as h′(x)=7 − (x mod 7) This yields the sequence of hash functions hi(x)=(x mod b + i⋅ (7 − ( x mod 7)))mod b for i=0,1,…

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT