Divide and conquer recurrence relation

Eng67
Messages
21
Reaction score
0
I am at a loss on how to get the correct answer to this question.

How many comparisons are needed for a binary search in a set of 64 elements?

I know the formula f(n) = f(n/2) + 2

I know the correct answer which is 14.

No matter what I do I cannot come up with this answer.

Please help me by showing a couple of steps and I can break down this wall!
 
Physics news on Phys.org
f(n) = f(n/2) + 2
Yes, that is a recurrance relation. However, every recurrance relation, in order to be unique, must also involve an "initial condition". How many comparisons are needed to search a set containing 2 members?

You know that f(64)= f(32)+ 2. Okay, what is f(32)? Well, f(32)= f(16)+ 2. What is f(16)? Continue until you "hit bottom"- that is until you reach f(2).
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top