Fixed InterpolationSearch getting caught on missing element.
This commit is contained in:
parent
b97fb17561
commit
d9735ec2bd
@ -53,6 +53,14 @@ public class InterpolationSearch {
|
|||||||
this.divisions++;
|
this.divisions++;
|
||||||
} else {
|
} else {
|
||||||
probe = high;
|
probe = high;
|
||||||
|
if (array[probe] != key) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Checks if it passed the element due to it not being in list. */
|
||||||
|
if (array[high] < key || array[low] > key) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
/* Checks if the key is less than the probe's value */
|
/* Checks if the key is less than the probe's value */
|
||||||
if (array[probe] > key) {
|
if (array[probe] > key) {
|
||||||
|
Loading…
Reference in New Issue
Block a user