Chapter 2: Problem 4
Show that the worst-case time complexity for Binary Search (Algorithm 2.1) is given by \(W(n)=[\lg n]+1\) When \(n\) is not restricted to being a power of \(2 .\) Hint. First show that the recurrence equation for \(W(n)\) is given by \(W(n)=1+W\left(\left\lfloor\frac{n}{2}\right\rfloor\right) \quad\) for \(n>1\) \(W(1)=1\) To do this, consider even and odd values of \(n\) separately. Then use induction to solve the recurrence equation.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.