Practice mode Data Structures

Keys 23, 34 and 45 are inserted in that order into a hash table of size 11 using h(k) = k mod 11 and quadratic probing, h(k, i) = (h(k) + i²) mod 11. At which index is 45 stored?

Correct answer A. 5

Explanation

All three keys hash to 1. 23 takes index 1. 34 tries 1, then 1 + 1² = 2, which is free. 45 tries 1, then 2 (both occupied), then 1 + 2² = 5, which is free. Linear probing would have placed 45 at 3, so quadratic probing jumps further away, which reduces primary clustering.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.