in binary search we usually use the formula mid=(low+high)/2 for finding the middle value of these values.can somebody tell me how this formula was derived

This is not a formula its a logic

In binary search element is compared with element which is at middle of an array so, for deriving middle element we have to add first and last index and divide it by 2 As we do in maths

1 Like

but i am confused that how we came to know that (high+low)/2 will give the midddle element

Study Airthematic progession in maths im sure u will get much better

ok i will try

Since the array is sorted in Binary search, it will give the mid point between highest element and lowest element. It won’t give the middle element of the array. Since the mid point is now known to you, you will apply divide and conquer to get your result faster.