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 d9735ec2bd

View File

@ -53,6 +53,14 @@ public class InterpolationSearch {
this.divisions++;
} else {
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 */
if (array[probe] > key) {