Show that the worst-case time complexity for Binary Search is given by when n is not restricted to being a power of 2. Hint: First show that the recurrence equation for W(n) is given by T(1) = 1 To do this, consider even and odd values of n separately. Then use induction to solve the recurrence equation. I understand how to find this with base 2 but totally lost otherwise? Solution Hi there, The time to search in an array of N elements is equal to the time to search in an array of N/2 elements plus 1 comparison. T(N) = T(N/2) + 1 Now we re-write the function in recurrence. T(N) = T(N/2) + 1 T(N/2) = T(N/4) + 1 T(N/4) = T(N/8) + 1 …… T(4) = T(2) + 1 T(2) = T(1) + 1 Next we sum up the left and the right sides of the equations above: T(N) + T(N/2) + T(N/4) + T(N/8) + … +T(2) = T(N/2) + T(N/4) + T(N/8) + … +T(2) + T(1) + (1 + 1 + … + 1) The number of 1’s on the right side is LogN Finally, we cross the equal terms on the opposite sides and simplify the remaining sum on the right side, we get, T(N) = T(1) + LogN T(N) = 1 + LogN as T(1)=1 The worst case time complexityof binary search is: T(N) = O(LogN) .