This preview shows pages 1–2. Sign up to view the full content.
CS 3110 Lecture 20
Recursion trees and master method for
recurrence relations
Note:
this page uses the following special characters: Greek capital letter theta: (Θ), Greek capital letter omega (Ω), minus sign
(−). If these characters do not appear correctly, your browser is not able to fully handle HTML 4.0, and some of the following text
will likely not have the correct appearance.
Recursion trees
A
recursion tree
is useful for visualizing what happens when a recurrence is iterated. It diagrams the tree of
recursive calls, and the amount of work done at each call.
For instance consider the recurrence
T(n)=2T(n/2) + n
2
.
The recursion tree for this recurrence is of the following form:

n
2

/
\

(n/2)
2
(n/2)
2
height=

/
\
/
\
lg n

(n/4)
2
(n/4)
2
(n/4)
2
(n/4)
2

/
\
/
\
/
\
/
\

.

.

.
Generally it is straightforward to sum across each row of the tree, to obtain the total work done at a given
level:

n
2
n
2

/
\

(n/2)
2
(n/2)
2
(1/2)n
2
height=

/
\
/
\
lg n

(n/4)
2
(n/4)
2
(n/4)
2
(n/4)
2
(1/4)n
2

/
\
/
\
/
\
/
\

.

.

.
This is a geometric series, and thus in the limit the sum is
O(n
2
)
. In other words the depth of the tree in this
case does not really matter, the amount of work at each level is decreasing so quickly that the total is only a
constant factor more than the root.
Recursion trees can be useful for gaining intuition into the closed form of a recurrence, but are not a proof
(and in fact it is easy to get the wrong answer with a recursion tree, as is the case with any method that
includes ''.
..'' kinds of reasoning). As we saw last time, a good way of establishing a closed form for a
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 '07
 GIAMBATTISTA,A

Click to edit the document details