Binary Search example step by step
BINARY SEARCH
In binary searching, first thing is to do sorting, because binary search can only perform on a sorted list. Best example of a binary search is dictionary. Dictionary is a sorted list of word definitions. Telephone directory is also a sorted list of names, addresses and numbers.
Advantages
- More efficient than linear search. For an array or list of N elements, perform at most log2N comparisons.
Disadvantage
- Requires that the elements of the list be in sorted order. For unsorted lists binary search will not work.
SEARCHING
Searching is the process of finding or locating an element or number in a given list.
Examples
- Looking for meaning of a word in dictionary
- Looking for a telephone number by giving name
- Looking for a name and address by giving telephone number
Other searching algorithms
- Exponential search
- Fibonacci search
- Interpolation search