You are on page 1of 10

Module-1[Lecture-6]

Recursion tree method

1
OBJECTIVES
After completing this section, you will be able to
 Understand recursion tree method to solve Recurrence of the form:

 [Decreasing function]

 [Dividing Function]

2
Recursion Tree method:
A recursion tree is a convenient way to visualize what happens when a
recurrence is iterated.
It is a pictorial representation of a given recurrence relation, which shows
how Recurrence is divided till Boundary conditions.

Recursion tree method is especially used to solve a recurrence of the form:

 [Decreasing function]

 where [Dividing Function]

3
Recursion Tree method…

In a recursion tree ,each node represents the cost of a single sub-problem


somewhere in the set of recursive problems invocations .
 we sum the cost within each level of the tree to obtain a set of
per level cost, and
 then we sum all the per level cost to determine the total cost of all levels
of recursion. That gives us a solution of given recurrence

Let us see how to solve recurrence of the form

 where [Dividing Function]

4
Solve the following recurrence using recurrence tree method:
…..(1)
Step1: First you make a recursion tree of a given recurrence.
(i) To make a recursion tree we have to compare the given recurrence (1)
with , you have to write the value of at root node. The number of child
of a Root Node is equal to the value of (here in recurrence (1)). So
initially, recursion tree be looks like as:

Fig (a)
Fig (b)

5
Solve the following recurrence using recurrence tree method:
…..(1)
b) Now we have to find the value of T(n/4) in figure (b) by putting (n/4) in place of n in
equation (1).That is

From equation (2), now will be the value of node having 3 branch (child nodes) each
of size T(n/16). Now each in figure-b will be replaced as follows:

6
Solve the following recurrence using recurrence tree method:
…..(1)
c) In this way, you can extend a tree up to Boundary condition (when
problem size becomes 1). So the final tree will be looks like as:

7
Solve the following recurrence using recurrence tree method:
…..(1)
d) Now we find the per level cost of a tree, Per-level cost is the sum of the
costs of each nodes within each level (called row sum). Here per level cost
is shown in figure-d.

Fig-(d) 8
Solve the following recurrence using recurrence tree method:
…..(1)

e) Finally, the total cost is the sum of the costs of all levels (called column
sum), which gives the solution of a given Recurrence. Thus,
Total cost=

Fig-(d) 9
Solve the following recurrence using recurrence tree method:
…..(1)
e) Finally, the total cost is the sum of the costs of all levels (called column
sum), which gives the solution of a given Recurrence. Thus,
Total cost=
=

It’s a G.P series (r<1):


=

(using property of log: )

10

You might also like