Binary Trees in Bridges

BinTreeElement<E> implements a binary tree element in BRIDGES and is inherited from Element<E>



How does the BinTreeElement<E> work?

BinTreeElement<E> is another type of container that has two links pointing to its two children, also binary tree elements. By convention, these two links are called "left" and "right and the top of the tree is referred to as the "root".



In the example above, Root has two links, so calling Root.getLeft() will return the TreeElement T1 and calling Root.getRight() will return the TreeElement T2.

Note that there is no pointer from T1 or any other element back to its root.

How does a BinTreeElement<E> differ from a DLelement<E>?

Structurally, DLelement<E> and TreeElement<E> are similar with 2 emanating links, but they are used in very different data structures. In a doubly linked list, the links point to the immediately following and previous element, while in the binary tree they point to its two children(recursively, as can be seen in the above example).


See also

This tutorial gives an introduction to the usage of binary trees. You can find the complete documentation of the features in the Doxygen documentation of the following classes and functions:

  1. BinTreeElement [Java] [C++] [Python]
  2. Tree [Java] [C++] [Python]
  3. Element [Java] [C++] [Python]
  4. ElementVisualizer [Java] [C++] [Python]
  5. LinkVisualizer [Java] [C++] [Python]
  6. Color [Java] [C++] [Python]

BinTreeElement - BRIDGES Example: A Huffman Coding Tree

Java
C++
Python

	  

	  

	  

Bridges Visualization

Well done! You’ve just created your Bridges Binary Tree project!

Styling a Binary Tree with BRIDGES

Just like any node link visualization, the nodes and links of a binary tree can be styled. This involve the ElementVisualizer of each node and the LinkVisualizer of each link. They can be used to change the size, color, and shape attribute of the visualization and attach a label to the different component.

An example is provided here to style the previous binary tree.

Java
C++
Python

	  

	  

	  

Bridges Visualization

Well done! You’ve just created your Bridges Binary Tree project!