Processing math: 100%
1 / 8 Settings
<<<>>>

To find the cost of binary search in the worst case, we can model the running time as a recurrence and then find the closed-form solution. Each recursive call to binarySearch cuts the size of the array approximately in half, so we can model the worst-case cost as follows, assuming for simplicity that n is a power of two.
Θ(n)=Θ(n/2)+1,Θ(1)=1

Created with Raphaël 2.1.2
Proficient Saving... Error Saving
Server Error
Resubmit