1
$\begingroup$

I'm just confused, cause from my knowledge recurrence is applied mostly to recursive procedures or divide and conquer techniques etc.

$\endgroup$

1 Answer 1

3
$\begingroup$

Sure.

The cost of searching a list of length zero is zero; the worst-case cost of searching a list of length $n$ is one greater than the cost of searching a list of length $n-1$. So $$\begin{align*}T(0)&=0 \\ T(n)&=T(n-1)+1\,,\end{align*}$$ with solution being, as you'd expect, $T(n)=n$.

$\endgroup$
1
  • $\begingroup$ Heh. Beat me by seconds. Nice explanation. $\endgroup$ Oct 18, 2014 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.