0% found this document useful (0 votes)
63 views

Chapter 2 - Asymptotic Notation (Recursion Tree)

The recursion tree method is a pictorial representation of an iterative method in the form of a tree. At each level of the tree, nodes are expanded to represent the subproblems. The recursion tree method is useful for analyzing divide and conquer algorithms. It represents the cost of each subproblem as nodes in the tree. To determine the total cost, the costs of each level are summed. The recursion tree method can generate an estimate of the runtime that can then be verified using the substitution method.

Uploaded by

Ren Zx
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Chapter 2 - Asymptotic Notation (Recursion Tree)

The recursion tree method is a pictorial representation of an iterative method in the form of a tree. At each level of the tree, nodes are expanded to represent the subproblems. The recursion tree method is useful for analyzing divide and conquer algorithms. It represents the cost of each subproblem as nodes in the tree. To determine the total cost, the costs of each level are summed. The recursion tree method can generate an estimate of the runtime that can then be verified using the substitution method.

Uploaded by

Ren Zx
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Recursion Tree Method

1. Recursion Tree Method is a pictorial representation of an iteration method which is in


the form of a tree where at each level nodes are expanded.

2. In general, we consider the second term in recurrence as root.

3. It is useful when the divide & Conquer algorithm is used.

4. It is sometimes difficult to come up with a good guess. In Recursion tree, each root
and child represents the cost of a single subproblem.

5. We sum the costs within each of the levels of the tree to obtain a set of pre-level costs
and then sum all pre-level costs to determine the total cost of all levels of the recursion.

6. A Recursion Tree is best used to generate a good guess, which can be verified by the
Substitution Method.

Example 1

Consider T (n) = 2T + n2

We have to obtain the asymptotic bound using recursion tree method.

Solution: The Recursion tree for the above recurrence is

(n2)
So, the amount of work done is lg n ==> (n/2i)2 = 1 (base case) i = lg n

𝑛
∑lg 𝑛
𝑖=0(2𝑖 ) = (n )
2 2

Example 2: Consider the following recurrence

T (n) = 4T + n

Obtain the asymptotic bound using recursion tree method.

Solution: The recursion trees for the above recurrence

(n2)
Example 3: Consider the following recurrence

Obtain the asymptotic bound using recursion tree method.

Solution: The given Recurrence has the following recursion tree

(n logn)

Each level does work of size n; if we just know the height of the tree , i, the total work is ni.
The tree stops when the lead is of size 1. The hard part is to figüre out the formula based on
the height:

When we add the values across the levels of the recursion trees, we get a value of n for
every level. The longest path from the root to leaf is

i is the height of the tree and

So the total work is (log3/2n)n or O(nlog3/2n) or O(nlogn).

You might also like