Class Tree::BinaryTreeNode
In: lib/tree/binarytree.rb
Parent: TreeNode

Provides a Binary tree implementation. This tree node allows only two child nodes (left and right childs). It also provides direct access to the left and right children, including assignment to the same.

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 will be the second node. If only one child is present, then this will be the left child.

Returns true if this is the left child of its parent. Always returns false if this is the root node.

Returns true if this is the right child of its parent. Always returns false if this is the root node.

Returns the left child node. Note that left Child == first Child

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

Returns the right child 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. If a previous child existed, it is replaced.

Swaps the left and right children with each other

[Validate]