3_recurrences.v3

3_recurrences.v3 - Recurrences David Kauchak Recurrence: a...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Recurrences David Kauchak Recurrence: a function that is defined with respect to itself on smaller inputs. Why are we concerned with recurrences? The computational costs of divide and conquer algorithms and, in general, recurive algorithms, can often be described easily using recur- rences. The problem? Recurrences are easy to define, but they dont readily express the actual computational cost of the algorithm. We want to remove the self-recurrence and determine a more understandable form of the func- tion. The methods Each approach will provide you with a different way for analyzing re- currences. Depending on the situation, one or more of the approaches may be applicable. Substitution method: When we have a good guess of the solution, we start with that then prove that it is correct Recursion-tree method: If we dont have a good guess of the solution, looking at the recursion tree can help us. Then, we prove it is correct with the substitution method. Master method: Provides solutions for recurrences of the form: T ( n ) = aT ( n/b ) + f ( n ) The substitution method: Guess the form of the solution. Assume its correct and show that the solution is appropriate using a proof by induction. 1 T ( n ) = braceleftBigg d if n = 1 T ( n ) = T ( n/ 2) + d otherwise Halves the input at each iteration and does a constant amount of work, e.g. binary search - Guess: O (log 2 n ) To show that T ( n ) = O (log 2 n ), we need to find constants c and n such that...
View Full Document

This document was uploaded on 05/25/2011.

Page1 / 8

3_recurrences.v3 - Recurrences David Kauchak Recurrence: a...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online