Monday , October 24 2016
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.

Also See:   Multiple Inheritance in JAVA


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.


Check Also

Program for Matrix Multiplication in JAVA

Announcement: Know how other students are getting higher education from abroad (US, UK, Germany) and ...

Leave a Reply

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

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