Illustration of Binary search:
An illustration to search for the key of 91 in the vector is as shown below:
The table below shows what will happen in each iteration of this search algorithm.
The key found in the fourth element of the vector.
Another illustration: search for the key 82:
The value of low cannot be greater than high; this means that the key is not in the vector. Therefore, the algorithm repeats until either the key is found or until low > high, that means the key is not there.