SUNY Geneseo Department of Computer Science


Introduction to Recurrence Relations

{Date}

CSci 141, Spring 2004
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Misc

Hand out Lab 6

Lab 4 Solution is on the Web

Questions?

Recurrence Relations

Key tool for performance analysis of recursive algorithms

Section 7.2.1

Recurrence relations and math

Interest example

Non-recursive version

Prove equivalence inductively

Closed forms

Example Recurrence

Find closed form for

What is f(3)?

Closed form

Prove this

Application to Algorithms

We started to see how the number of operations a recursive algorithm does can be "counted" by a recurrence relation -- finish it now.

For example, just how many disk moves does the towers of Hanoi algorithm require?

    solve( n, source, dest, spare )
        if n > 0
            this.solve( n-1, source, spare, dest )
            this.move( source, dest )
            this.solve( n-1, spare, dest, source )

M(n) is number of disk moves towers of Hanoi algorithm does to solve an n-disk puzzle

Closed form

[Sum of  Powers of 2 from 0 to n-1 = 2^n - 1]

Next

Read Section 7.2.2


Next Lecture