Binary Sreach Algorithm : Optimized way to get the index of the mid element

The classical way to find the mid element in an array would be (start+end)/2. 

But integershave a limited range and what if the size of the array is too large and (start+end) exceeds the range of integers in java??

Hence, inorder to make optimize it I learnt a new way to find the mid element which is  start + (end-start)/2 in this way, even if the size of the array exceeds the integer range, the end-start would make it smaller. 

Popular posts from this blog

The third parameter - Event bubbling and Event capturing

Abstract classes