SUNY Geneseo Department of Computer Science


Ordered Trees

{Date}

CSci 141, Spring 2005
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Questions?

Typo? Last line on page 439 should read "...or is in each of T-prime's children..."

Ordered Trees

Section 13.3 through 13.3.4

Binary trees can maintain sorted collections

"Inorder" property:

Inductions on height of tree

Proof by contradiction

Traverse algorithm visits no node twice and makes exactly n visits

Moral: trees can support fast "database" operations

Algorithms for adding an item (insertion) and finding an item (search)

Start inserting from greatest element

[A "Tree" that Is a List to the Left]

What sort of induction do the proofs in this reading use?

[Subtrees Each Have Distinct Heights]

Performance Analysis of Simple Tree Algorithms

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

How would you derive the number of primitive tree messages this sends to traverse a tree of n items?

Recurrence relation

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

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


Next Lecture