You are here

Binary Tree Object Model

26 July, 2019 - 09:51
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at http://cnx.org/contents/402b20ad-c01f-45f1-9743-05eadb1f710e@37.6

Definition: Binary Tree

A (mutable) binary tree, BiTree, can be in an empty state or a non-empty state:

  • When it is empty, it contains no data.
  • When it is not empty, it contains a data object called the root element, and 2 distinct BiTree objects called the left subtree and the right subtree.

We implement the above object structure with a combination of state/composite/visitor patterns, in a manner analogous to LRStruct.

Download the source here:

Below is the public interface of the binary tree framework. Download the javadoc documentation here.

media/image6.png
Figure 4.6 Public interface of the binary tree framework 

The implementation details are given in the following UML class diagram. Download the javadoc documentation here.

media/image7.png
Figure 4.7 UML class diagram