EmbLogic's Blog

Binary Search

Searching is one of the most important task for any programmer. We have too many techniques to do this ,among all the techniques we are using Binary search right now because
Binary search is too good for searching a number in a large number-list it takes less time.
The necessary condition to perform Binary search is that the list should be Shorted.
Algo:
It break down the list in to two parts in every iteration
the number you want to search is compare with lowest number , middle number, largest number of the shorted list,
*if the number you want to search is less then the middle number then
lowest number will be same
the previous middle number will be consider as largest
new middle number will be assigned using ((a+b)/2)
// because number is greater then the lowest number but less the the middle number , so no need to . search it in a number range above the middle number.
*if the number you want to search is greater then the middle number then
largest number will be same
the previous middle number will be consider as smallest
new middle number will be assigned using ((a+b)/2)
// because number is greater then the middle number but less then the largest number , so no need to . search it in a number range below the middle number.

see the Programme
follow the link.

https://drive.google.com/drive/folders/0B-dkmspcBW7aZnRVZTM5NklELTA?usp=sharing

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>