Question

Double hashing is scheme for resolving collisions that uses two hash functions HCk, m) and hCk,m). It is similar to linear hashing except that instead of changing the index by 1, the value of the second hash function is used From the view of the general scheme, the Io(k, mHCk, m) Hi(k, m) -(H(k, m)+ h(k,m)) mod m H2 (k, m) = (H(k, m)+ 2 h(k,m)) mod m hash functions are. Hi (k, m) (H(k , m)+ h(k , m)) mod m values. As with linear hashing, the hash function Hi(k, m) CHi-1(k, m)+ h(k, m)) mod m can be defined in terms of the previous You must be careful when defining the second hash function.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Double hashing is a collision resolving technique in hashing. Double hashing used the idea of implementing second hash key when occur the collisions.

Double hashing cab be don using the following equation

(Hash1(key)+i*hash2(key)) % size of the table.

Here hash1() and hash2() are two hash functions

I is probe value

In general first hash function is hash1(key) = key % table size.

A popular second hash function is hash2(key) = any primenumber – (key % primenumber) where prime number is a prime small than the table size.

A good hash function in double hashing is

1.      Its never evaluate to zero

2.      Make sure that the all cells can be probed.

Suppose hash1(key) = key%15

            Hash2(key)=7-(key%7)

Here 7 is prime number which is less than 15.

Let us consider the following data and insert into table

10

15

8

9

12

13

14

68

88

39

86

95

28

40

42

Hash table is :

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

39

95

8

9

10

86

12

88

14

Above data is inserted without any collisions.

Now apply double hashing using above method

Key

Hash1 & Hash 2

Probe(i)

address

remarks

68

8

1

10

collision

2

2

12

collision

3

14

collision

4

1

1 is index for 68

39

9

1

12

collision

3

2

0

collision

3

3

collision

4

6

6 is index for 39

28

13

1

5

collision

7

2

12

collision

3

4

4 is index for 28

Implement same for 40 now it is 7

Implement same for 42 now it is 2

Finally the hash table for the given data is

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

68

41

39

28

95

39

40

8

9

10

86

12

88

14

Add a comment
Know the answer?
Add Answer to:
Double hashing is scheme for resolving collisions that uses two hash functions HCk, m) and hCk,m)....
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
  • Part 5. Suppose that your hash function resolves collisions using the open addressing method with double...

    Part 5. Suppose that your hash function resolves collisions using the open addressing method with double hashing. The double hashing method uses two hash functions h and h'. Assume that the table size N = 13, h(k) = k mod 13, h'(k) = 1 + (k mod 11), and the current content of the hash table is: 0 1 2 3 6 7 8 9 10 11 12 4 17 5 98 If you insert k = 14 to this...

  • 3. (20 points) In open addressing with double hashing, we have h(k,i) hi(k)+ih2(k) mod m, where h...

    3. (20 points) In open addressing with double hashing, we have h(k,i) hi(k)+ih2(k) mod m, where hi(k) and h2(k) is an auxiliary functions. In class we saw that h2(k) and m should not have any common divisors (other than 1). Explain what can go wrong if h2(k) and m have a common divisor. In particular, consider following scenario: m- 16, h(k) k mod (m/8) and h2(k)-m/2 and the keys are ranged from 0 to 15. Using this hash function, can...

  • 1. Using closed hashing with double hashing to resolve collisions insert the following keys into a...

    1. Using closed hashing with double hashing to resolve collisions insert the following keys into a table with 11 slots, numbered 0 through 10. The hash functions to be used are H1(k)k(mod11) and H2(k)- Rev(k + 1) (mod11) The function REV reverses the decimal digits like Rev(376) 673. Show the hash table after all nine keys have been inserted. Be sure to indicate how H1 and H2 are used. Keys: 4, 3, 2, 8, 33, 17, 24, 35, 46

  • 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...

  • Need help on problems 3 and 4 only thanks in advance. Define the following terms: hash...

    Need help on problems 3 and 4 only thanks in advance. Define the following terms: hash table hash function perfect hash function What is a collision? Explain three ways of handling collisions (a program is not needed; a clear brief explanation suffices). Consider a hashing scheme that uses linear probing to resolve collisions. Design an algorithm (no code necessary) to delete an item from the hash table. What precautions do you need to take to make it work properly? Given...

  • 10. Submission In this question you will work with a hash table that uses double hashing. The hash table is size 11, the primary hash function is h(K)-K mod 11, and the secondary hash function is hp(...

    10. Submission In this question you will work with a hash table that uses double hashing. The hash table is size 11, the primary hash function is h(K)-K mod 11, and the secondary hash function is hp(K)-(K mod9) +1 Take an empty hash table. Take your student number and split it into 4 2-digit integers. Insert each of these 2-digit numbers in the order in which they appear in your student number into the empty heap. Then insert the values...

  • C programming Problem 3 [Set via Hashing] As mentioned in the lecture, a hash table can...

    C programming Problem 3 [Set via Hashing] As mentioned in the lecture, a hash table can be used to implement a Set ADT. Let's try to use the template below to implement a Set with double hashing. Here we assume the Set contains names with 3 characters long. Since it is a Set, we do not need to have an explicit value for each key. We will use a token value of 1 if a name belongs to the Set....

  • 2. (10 points.) The procedure HASH-SEARCH takes a hash table T[O : m-1) and a key...

    2. (10 points.) The procedure HASH-SEARCH takes a hash table T[O : m-1) and a key k as its parameters. Each element of T is either a key or NIL. The procedure searches for k in T by probing. If it finds k, then it returns the index j where k appears in T. If it cannot find k, then it returns -1. (A procedure very much like HASH-SEARCH is discussed on pages 269–274 of Cormen.) HASH-SEARCH(T, k) i= 0...

  • C programming Let's try to use the template below to implement a Set with double hashing....

    C programming Let's try to use the template below to implement a Set with double hashing. Here we assume the Set contains names with 3 characters long. Since it is a Set, we do not need to have an explicit value for each key. We will use a token value of 1 if a name belongs to the Set. Let's reuse the exact hash functions we have seen in example in Part 7 of the lecture notes, page 3. As...

  • in C++ Code should work for all cases In this assignment you are requested to implement...

    in C++ Code should work for all cases In this assignment you are requested to implement insert, search, and delete operations for an open-addressing hash table with double hashing. Create an empty hash table of size m= 13. Each integer of the input will be a key that you should insert into the hash table. Use the double hashing function h{k, i) = (hı(k) + ih2(k)) mod 13 where hi(k)= k mod 13 and h2(k) = 1+(k mod 11). The...

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