Trees

Steven J. Zeil

Old Dominion University, Dept. of Computer Science

Table of Contents

1. Tree Terminology
2. Tree Traversal
2.1. Kinds of Traversals
2.2. Recursive Traversals
3. Example: Processing Expressions
3.1. The Data Structure
3.2. The Application
3.3. Expression Interface
3.4. Printing Expressions
3.5. Distributive Law
3.6. Simplifying Expressions
4. Example: Processing XML
4.1. Processing XML as a Tree
5. Using Trees for Searching
5.1. Definition: Binary Search Trees
5.2. The Binary Search Tree ADT
5.3. Searching a Binary Tree
5.4. Inserting into Binary Search Trees
5.5. How Fast Are Binary Search Trees?

Most of the data structures we have looked at so far have been devoted to keeping a collection of elements in some linear order.

Trees are the most common non-linear data structure in computer science.

Trees also turn out to be exceedingly useful in implementing fast searching and insertion.