CSCE 235

Handout 23: Some Types of Trees

Assigned April 25, 2003 

 

 

Binary Search Tree

 

A binary search tree is a binary tree in which each child of a vertex is designated as a right or left child, and each vertex is labeled with a key, which is one of the items.  Furthermore, vertices are assigned keys so that the key of a vertex is both larger than the keys of all vertices in its left subtree and smaller than the keys of all vertices in its right subtree.

 

Applications:  Sorting, Search, Storage

 

Game Trees

 

A game tree is a tree where the vertices represent the positions that a game can be in as it progresses and the edges represent legal moves between these positions. Game trees are usually large and all symmetric positions of a game may be represented by the same vertex.  On the other hand, the same position of a game may be represented by different vertices if different sequences of moves lead to this position.  The root represents the starting position.  The leaves of a game tree represent the final positions of a game and each is a assigned a payoff to the first player.

 

Applications:  Game playing, Decision making, Automated Reasoning

 

Spanning Trees

 

Let G be a simple graph.  A spanning tree of G is a subgraph of G that is a tree containing every vertex of G.  If G is weighted, then a minimum spanning tree in a connected, weighted graph G is a spanning tree that has the smallest possible sum of weights of its edges.

 

Applications:  IP Multicasting, Network management, Optimization

 

Traversal Algorithms

 

Procedures for systematically visiting every vertex of an ordered rooted tree are called traversal algorithms.

 

Definition 1.  Let T be an ordered rooted tree with root r.  If T consists only of r, then r is the preorder traversal of T.  Otherwise, suppose that  are the subtrees at r from left to right in T.  The preorder traversal begins by visiting r.  It continues by traversing  in preorder, then  in preorder, and so on, until  is traversed in preorder.

 

Definition 2.  Let T be an ordered rooted tree with root r.  If T consists only of r, then r is the inorder traversal of T.  Otherwise, suppose that  are the subtrees at r from left to right in T.  The inorder traversal begins by visiting  in inorder, then visiting r.  It continues by traversing in inorder, and so on, until  is traversed in inorder.

 

Definition 3.  Let T be an ordered rooted tree with root r.  If T consists only of r, then r is the postorder traversal of T.  Otherwise, suppose that  are the subtrees at r from left to right in T.  The postorder traversal begins by visiting  in postorder, then  in postorder, and so on, until  is traversed in postorder, and ends by visiting r.

 

Based on (Rosen 2003).