1
$\begingroup$

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

$\endgroup$
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$
  • $\begingroup$ Heh. Beat me by seconds. Nice explanation. $\endgroup$ – Rick Decker Oct 18 '14 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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