This is just my thought on run time of a binary search: if you are allowed to make 1 comparison, you can search a sorted list of length 1, but if you are allowed to perform 2 comparisons, you can search a list of length 3 (if the list is sorted [1,2,3], you first search the middle [2] and depends on the result, you continue down the left[1]/right[2], which is just a sorted list of length one)
it is pretty obvious that when you are given an extra comparison, the length of the sorted list you can search is doubled + 1
$f(x+1) = 2f(x) + 1$
I want to represent $f(x)$ in terms of x, the relation between list length and number of comparison required. the answer is $$f(x) = 2^x -1$$ However, I want to solve it using math...but I don't remember how to solve a recursively defined function like this
thanks
Let $g(x)=f(x)+1$. Then $$ g(x+1)=f(x+1)+1=2f(x)+1+1=2(f(x)+1)=2g(x). $$ This suggests a representation of the form $g(x)=g(0)2^x$ so that $f(x)=g(x)-1=g(0)2^x-1$.
Conversely, you can check that all $f(x)=c2^x-1$ satisfy your functional equation.