You are on page 1of 7

# Divide and Conquer

## In general, run time is T (n)=bT ( n )+ f (n)

b is number of subproblems

Equation 3.8

## divide into subproblems

merge subproblem solutions
combination of the two

## how are nonrecursive cost distributed

cost of leaves

Critical Exponent

## Recursion tree properties

lg (n)
base case (leaves) at depth D=
lg (c)
D
L=b
nodes (leaves) at depth D are
lg(b)
lg n
lg(c)

lg(b)
E=
lg(c)

Lemma 3.14

## The number of leaves in the recursion tree for

Equation 3.8 is approximately L=n E where E is
the critical exponent definition is the previous
slide
Cost of recursion tree is at least L=n E

Lemma 3.15

## With the previous notation

1)The recursion tree has depth

, so there are
D=lg (n)/lg(c)

## 2)The zeroth row-sum is F(n), the non-recursive cost of

the root
3)The Dth row-sum is n E, assuming the base cases cost
1 or (n E )
4)The value of T(n), the solution of Equation 3.8, is the
sum of the nonrecursive costs of all the nodes in the
tree, which is the sum of the row-sums

Theorem

## Assuming the notation in previous slides and T(n)

defined in Equation 3.8

## 1)If the row-sums form an increasing geometric

series, then T (n)(n E )
2)If the row-sums remain about constant,
T (n)(f (n)log (n))

## 3)If the row-sums form a decreasing geometric

series, then T (n)(f (n)) (proportional to the nonrecursive costs.

## The recurrence equation

n
T (n)=bT ( )+ f (n)
c

## 1)If f (n)O(n E )for some positive then

T (n)(n E ) which is proporational to the number of leaves in the
recursion tree
E

, then

3) If f (n)(n

E +

## )for some positive , then

T (n)(f (n)) which is proportional to the nonrecursive cost at the

## T (n)=bT (nc)+f (n)

Since subproblem size decrease by a constant the tree depth is about D = n/c

Even if f(n) = 1
n/c

## T (n)= b f (ncd )=b

d

d=0

n/ c

n/ c

f (ch)
bh
h=0

which is exponential in b

If b = 1 better case
n/c

n/c

## T (n)= f (ncd)= f (ch)

d=0

If f(n) is polynomial

h=0

1
f ( x) dx

c 0