Section 5.3: Decision Trees

Abstract:

Decision trees are defined, and some examples given.

Decision Tree Definition and Terminology

Definition: a decision tree is a tree in which

Examples of decision trees in action

Exercise #2, p. 388.

Exercise #4, p. 388.

Lower Bounds on Searching

In particular about binary trees:

  1. Any binary tree of depth d has at most tex2html_wrap_inline135 nodes. (Proof: look at the full binary tree, as it has the most nodes per depth.)
  2. Any binary tree with m nodes has depth tex2html_wrap_inline139 .
The proof of the latter is by contradiction and interesting (p. 384): By contradiction, tex2html_wrap_inline139 . These facts lead to the following

Theorem (on the lower bound for searching):

Any algorithm that solves the search problem for an n-element list by comparing the target element x to the list items must do at least tex2html_wrap_inline153 comparisons in the worst case.

If, in its worst case, an algorithm does at most this lower bound on worst case behavior is an optimal algorithm in its worst-case behavior.

Binary Search Tree

The Binary search algorithm required a sorted list; if your data is unsorted (it may be changing dynamically in time, if you are updating a database of customers, for example), you can populate a tree which approximates a sorted list, and then use a modified search algorithm (binary tree search) to search the list. A binary search tree is constructed as follows:

Practice #25, p. 386.

The binary tree search algorithm works in the same way as you'd introduce a new node, only the algorithm terminates if

In this case the binary search tree serves as the decision tree for the binary tree search algorithm.

Exercise #9, p. 389.

Sorting

Examine Figure 5.55, p. 387. In this case, we're sorting a three-element list using a decision tree. The author calls this a stupid algorithm (actually, ``not particularly astute''): why?

Practice #26, p. 387.

Assuming no equal elements in the list, then this is indeed a binary (rather than ternary tree, with = included). In this case, we can also get a lower bound on sorting a list with n elements:

This is the Theorem on the lower bound for sorting: that you have to go to at least a depth of tex2html_wrap_inline175 in the worst case.



LONG ANDREW E
Thu Mar 7 19:35:38 EST 2002