SUNY Geneseo Department of Computer Science


Analysis of Tree Search

{Date}

CSci 141, Fall 2003
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Questions?

Binary Tree Search

    boolean search( x )
        if this.isEmpty()
            return false
        else if x.compareTo( this.root() ) > 0
            return this.right().search( x )
        else if x.compareTo( this.root() ) < 0
            return this.left().search( x )
        else
            return true

Correctness proof

Or prove this by induction on height

How fast is it?


Next Lecture