I am doing a practice question from Data Structures Practice
The Question
1.Linear Probing will (circle one):
i.gradually degrade in performance as more values are inserted
ii.May not find a location on the next insertion
iii.None of the above
2.Quadratic Probing will (circle one):
i.gradually degrade in performance as more values are inserted
ii.May not find a location on the next insertion
iii.None of the above
According to the answer key(from the link), the answer to 1 is i and the answer to 2 is ii.
I agree with the answer question 1. Linear probing will explore all possibilities and wrap to the beginning of the hashtable if needed. Therefore it will find a location on the next insertion. If you insert a bunch of values that map to the same bucket or near one bucket, clustering will result and performance will degrade.
I understand why the the answer to question 2 isn't i. Quadratic increment probs by different increments to avoid the clustering issue. However can some explain the intution behind how quadratic probing "may not find a location on the next insertion"
A quadratic probing function is defined with (from Quadratic Probing)
nth probe being ((h(k) + n2) mod TableSize) until the probe hits a zero(unoccupied)
From what I learned in my other question Quadratic Probing, it is possible for a quadratic probe to hit every bucket. Like the linear probe, the quadratic probe should also wrap tot he beginning of the hashtable if needed. Why then in this question, can a quadratic probe not find a location on the next insertion while a linear probe can?