@Test public void test(){ int result = Binary.Search(CommonData.SEQUENCE_ARRAY,3); System.out.println(result); }
public static int Search(int[] array, int data) { int low = 0; int high = array.length - 1; while (low <= high) { int partition = (low + high) / 2; if (data < array[partition]) { high = partition - 1; } else if (data > array[partition]) { low = partition + 1; } else { return partition; } } return -1; }
Binary { public static int Search(int[] array, int data) { int low = 0; int high = array.length - 1; while (low <= high) { int partition = (low + high) / 2; if (data < array[partition]) { high = partition - 1; } else if (data > array[partition]) { low = partition + 1; } else { return partition; } } return -1; } }
Binary { public static int Search(int[] array, int data) { int low = 0; int high = array.length - 1; while (low <= high) { int partition = (low + high) / 2; if (data < array[partition]) { high = partition - 1; } else if (data > array[partition]) { low = partition + 1; } else { return partition; } } return -1; }  }
Binary { public static int Search(int[] array, int data) { int low = 0; int high = array.length - 1; while (low <= high) { int partition = (low + high) / 2; if (data < array[partition]) { high = partition - 1; } else if (data > array[partition]) { low = partition + 1; } else { return partition; } } return -1; }  static int Search(int[] array, int data); }
Binary { public static int Search(int[] array, int data) { int low = 0; int high = array.length - 1; while (low <= high) { int partition = (low + high) / 2; if (data < array[partition]) { high = partition - 1; } else if (data > array[partition]) { low = partition + 1; } else { return partition; } } return -1; }  static int Search(int[] array, int data);  }