Binary search expected number of comparisons?

21 Views Asked by At

What is the expected number of comparisons needed to find a number (if it exists) in an array of [1,2,...,n] using binary search? I understand the limiting time complexity of binary search is $O(\log(n))$, but what is the expected value of the number comparisons?