1computer sciences department. objectives recurrences. substitution method, recursion-tree method,...

29
1 Computer Sciences Department

Upload: percival-haynes

Post on 19-Jan-2016

229 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 1

Page 2: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method
Page 3: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Objectives

• Recurrences.

Substitution Method,

Recursion-tree method,

Master method

Page 4: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 4

Recurrence

Page 5: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 5

A recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs.

Example: MERGE-SORT procedure could be described by

the recurrence:

recurrence

Page 6: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 6

Substitution Method,

Recursion-tree method,

Master method

Recurrence Methods

Page 7: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 7

The substitution method for solving recurrences entails two steps: 1. Guess the form of the solution. 2. Use mathematical induction to find the

constants and show that the solution works. The substitution method can be used to

establish either upper or lower bounds on a recurrence.

The substitution method

Page 8: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 8

Page 9: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 9

As an example, let us determine an upper bound on the recurrence

lgn/2=lgn-lg2

Page 10: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 10

A recursion tree is best used to generate a good guess, which is then verified by the substitution method.

Using recursion trees to generate good guesses.

The recursion-tree method

Page 11: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 11

Solution

Page 12: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 12

Solution

Page 13: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 13

Solution

Page 14: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 14

Solution

Page 15: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 15

Solution

Page 16: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 16

For example

We start by focusing on finding an upper bound for the solution.

create a recursion tree for the recurrence

we assume that n is an exact power of 4

Page 17: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 17

Page 18: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 18

Page 19: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 19guess

Page 20: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 20

Page 21: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 21

The master method

Page 22: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 22

Page 23: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 23

and

and

Conditions of using the master method

1

2

3

5

4

and

Page 24: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 24

Page 25: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 25

?

Try

Page 26: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 26

TRY (LAB)

Page 27: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 27

Page 28: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 28

Page 29: 1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method

Computer Sciences Department 29

Proof of the master theorem (no need)