SUNY Geneseo Department of Computer Science


Analyzing Tree Traversals

{Date}

CSci 141, Spring 2005
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Misc

Hand out Lab 12

Questions?

Performance Analysis of Tree Traversal Algorithms

    traverse()
        if ! this.isEmpty()
            this.getLeft().traverse()
            process this.getRoot()
            this.getRight().traverse()

Recurrence

Observation: actual distribution of n1 and n2 doesn't seem to matter

So:

Mini-assignment: find closed form for an "easy" version of above recurrence

Proofs: induction on n

What if we tried n1 = n2 = (n-1)/2?

Performance of Search-Style Algorithms

Section 13.3.5 (read this for Wednesday)

    search( x )
        if this.isEmpty()
            return false
        else if x == this.getRoot()
            return true
        else if x < this.getRoot()
            return this.getLeft().search( x )
        else
            return this.getRight().search( x )

Next Lecture