Friday , January 20 2017
Home / JAVA / ISC Class 12 / Binary Search Program in Java

Binary Search Program in Java

Binary search Program with Example:-  A binary search locates an item in a sorted array by repeatedly dividing the search interval in half. Initially interval include the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.


Binary Search Java Program


  • Output:-

    Enter the size of the array: 7

    Enter 5 numbers: 3 5 34 21 20 10 9

    The sorted numbers are:

    3 5 9 10 20 21 34

    Enter the number you want to search: 20

    The search number is on the index 5

  •  Output:-

    Item found on location: 2

  • Output:-

    We found 8 at position 4 in the list.


Also See:   Java program to find saddle point in a matrix

Check Also

Program for Matrix Multiplication in JAVA

Matrix Multiplication:– Here is given a Java Program for Matrix Multiplication also call matrix product. In ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.