if the array has 1000 elements, binary search will take around 10 steps.
The relationship between the number of elements and the number of steps can be mathematically explained using the concept of logarithms. In the case of 1000 elements, the base-2 logarithm of 1000 is approximately 10, which means that binary search will take around 10 steps to find the desired element
Log base 2 is the power to which the number 2 must be raised to obtain the value of n. For any real number x, log base 2 functions are written as. x = log2 n. Which is equal to. 2x = n.