Fixed InterpolationSearch getting caught on missing element.

This commit is contained in:
Jonathan Turner 2024-03-21 12:54:42 -04:00
parent b97fb17561
commit abb7b04383

View File

@ -53,6 +53,12 @@ public class InterpolationSearch {
this.divisions++;
} else {
probe = high;
if (array[probe] != key) {
break;
}
}
if (array[high] < key || array[low] > key) {
break;
}
/* Checks if the key is less than the probe's value */
if (array[probe] > key) {