Quadratic probing: show that (h(k)+c1i+c2i²) mod m covers all slots.
Analyze the quadratic probing: show that (h(k)+c1i+c2i²) mod m covers all slots..
Examples
Input: "test_input_1"
Output: "output_1"
Input: "test_input_2"
Output: "output_2"
Hints
Recall that quadratic probing uses a quadratic function of the form (h(k) + c₁i + c₂i²) mod m to resolve collisions. What must be true about the coefficients c₁ and c₂ for this function to generate distinct probes for each i in the range [0, m-1]?
Consider the properties of quadratic residues modulo m. If m is a prime number, how does the quadratic function (i² mod m) behave as i varies from 0 to m-1? How does this relate to the coverage of all slots in the hash table?
Prove that if m is a prime number and c₂ is a non-zero quadratic residue modulo m, then the function (h(k) + c₁i + c₂i²) mod m will generate all m distinct values as i ranges from 0 to m-1. What happens if m is not prime or c₂ is not a quadratic residue?
Quadratic probing: show that (h(k)+c1i+c2i²) mod m covers all slots.
Analyze the quadratic probing: show that (h(k)+c1i+c2i²) mod m covers all slots..