SUNY Geneseo Department of Computer Science


Introduction to Recurrence Analysis

Thursday, February 14

CSci 242, Spring 2013
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture

Misc

First hour exam postponed until Thursday Feb. 28

Questions?

Recurrence Relations and Analyzing Execution Time

Example: divide-and-conquer exponentiation

        power( x, n )
            if n == 0
                return 1
            else if n is even
                temp = power( x, n/2 )
                return temp * temp
            else
                temp = power( x, (n-1)/2 )
                return x * temp * temp
n T(n)
0 1
1 T(⌊n/2⌋) + 1 = T(0) + 1 = 2
2 T(⌊2/2⌋) + 1 = T(1) + 1 = 3
3 T(⌊3/2⌋) + 1 = T(1) + 1 = 3
4 T(⌊4/2⌋) + 1 = T(2) + 1 = 4

A simpler way to find a (asymptotic) closed form: the master method

Asymptotic notations

Asymptotically no more than (O), no less than (Omega), and the same as (Theta)

Next

More execution time analysis


Next Lecture