SUNY Geneseo Department of Computer Science


Ordered Binary Trees

{Date}

CSci 141, Fall 2004
Prof. Doug Baldwin

Return to List of Lectures

Previous Lecture


Questions?

Ordered Binary Trees

Reading summary: Sections 13.3.1 and 13.3.2

Traversal Time

    traverse
        if ! this.isEmpty()
            this.getLeft().traverse()
            visit root
            this.getRight().traverse()

[Trees with Traversal Visiting Subtree]

n = 0 f(n) = 1
n = 1 f(1) = 3 + f(0) + f(0)
  = 3 + 1 + 1
n = 2 f(2) = 3 + f(1) + f(0)
  = 3 + (3+1+1) + 1
n = 3 f(3) = 3 + f(1) + f(1)
  = 3 + (3+1+1) + (3+1+1)
  or 3 + f(2) + f(0)
  = 3 + 3+(3+1+1)+1 + 1

Next

Building and searching ordered trees

Read Sections13.3.3 and 13.3.4


Next Lecture