<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">public class BusquedaBinaria {

   public static int binarySearch(int[] array, int minLimit, int maxLimit, int value) {
      if (maxLimit &gt;= 0 &amp;&amp; array[minLimit] &lt;= value &amp;&amp; array[maxLimit] &gt;= value) {
         int mid = getMidValue(minLimit, maxLimit);
         System.out.println(String.format("LÃ­mite inferior %d lÃ­mite superior %d valor en el arreglo %d valor a buscar %d", minLimit, maxLimit, array[mid], value));
         if (array[mid] == value) {
            return mid;
         } else if (array[mid] &lt; value) {
            return binarySearch(array, mid + 1, maxLimit, value);
         }
         return binarySearch(array, minLimit, mid - 1, value);
      }
      return -1;
   }

   public static int getMidValue(int minLimit, int maxLimit) {
      return (maxLimit + minLimit) / 2;
   }

   public static void main(String[] args) {
      int value = 410;
      int[] array = { 10, 15, 20, 40, 50, 100, 120, 200, 400, 500, 600, 800, 2222};
      int result = binarySearch(array, 0, array.length - 1, value);
      System.out.println(String.format("Result %d", result));
   }
}
</pre></body></html>