Given a problem, how to come up with a recurrence equation?
For example :
Let S
be a set of n>0
distinct integers. Assume that n
is a power of 3
.
A ternary comparison can compare three numbers from the set S
and
order them from the largest to the smallest.
Describe an efficient algorithm that uses as few as possible ternary comparisons to find the largest number in the set S
.
This is one of the midterm question I had. I come up with
T(n) = 3T(n/3)+1
and other students come up with something else.
In general what to look for while finding a recursion for a problem?