Class | Tree::BinaryTreeNode |
In: |
lib/tree/binarytree.rb
|
Parent: | Tree::TreeNode |
Provides a Binary tree implementation. This node allows only two child nodes (left and right child). It also provides direct access to the left or right child, including assignment to the same.
This inherits from the Tree::TreeNode class.
Adds the specified child node to the receiver node. The child node’s parent is set to be the receiver.
The child nodes are added in the order of addition, i.e., the first child added becomes the left node, and the second child added will be the second node.
If only one child is present, then this will be the left child.
An exception is raised if two children are already present.
Returns true if the receiver node is the left child of its parent. Always returns false if it is a root node.
Returns true if the receiver node is the right child of its parent. Always returns false if it is a root node.
Returns the right child of the receiver node. Note that right child == last child unless there is only one child.
Returns nil if the right child does not exist.