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.

Methods

Public Instance methods

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 left child of the receiver node. Note that left Child == first Child.

Sets the left child of the receiver node. If a previous child existed, it is replaced.

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.

Sets the right child of the receiver node. If a previous child existed, it is replaced.

Swaps the left and right child nodes of the receiver node with each other.

[Validate]