SUNY Geneseo Department of Computer Science
{Date}
CSci 141, Spring 2005
Prof. Doug Baldwin
Ordered tree algorithm from lab? How to create unordered trees to test on?
OrderedTree t = new OrderedTree()
t.insertNode( new Integer(5) )
t.getLeft().insertNode( new Integer(10) )
....
Section 13.3.5
Search time depends on height more than number of items
Fully balanced tree has two children at every node in every non-leaf level, both subtrees fully balanced and of same height
Tree of height h, worst-case search time = Θ(h)
What if tree is totally unbalanced?
Search time in terms of n
Trees used to classify things - useful model for complex conditionals, AI, etc.
What can you say about how fast a decision tree with n possible outcomes can make a decision?
Height of tree in terms of number of leaves
Work it out
Reading said one more leaf than non-leaf nodes for fully-balanced trees
Decision time Θ(h) = Θ( log2n + 1 )
Other extreme? completely unbalanced tree?
Deletion from ordered trees
section 13.5.1