Packagede.polygonal.ds
Classpublic class BinaryTreeNode
InheritanceBinaryTreeNode Inheritance Object

A binary tree node from which you can build a binary tree. A Binary Tree is a simplified tree structure in which every node is only allowed to have up to two children nodes, which are called the left and right child.



Public Properties
 PropertyDefined By
  data : *
The node's data.
BinaryTreeNode
  left : BinaryTreeNode
The left child node being referenced.
BinaryTreeNode
  parent : BinaryTreeNode
The parent node being referenced.
BinaryTreeNode
  right : BinaryTreeNode
The right child node being referenced.
BinaryTreeNode
Public Methods
 MethodDefined By
  
Creates an empty node.
BinaryTreeNode
  
count():int
Recursively counts the total number of nodes including this node.
BinaryTreeNode
  
destroy():void
Recursively clears the tree by deleting all child nodes underneath the node the method is called on.
BinaryTreeNode
  
getDepth(node:BinaryTreeNode = null):int
Computes the depth of a tree.
BinaryTreeNode
  
inorder(node:BinaryTreeNode, process:Function):void
[static] Performs an inorder traversal on a tree.
BinaryTreeNode
  
isLeft():Boolean
Checks if the node is a left node relative to its parent node.
BinaryTreeNode
  
isRight():Boolean
Checks if the node is a right node relative to its parent node.
BinaryTreeNode
  
postorder(node:BinaryTreeNode, process:Function):void
[static] Performs a postorder traversal on a tree.
BinaryTreeNode
  
preorder(node:BinaryTreeNode, process:Function):void
[static] Performs a preorder traversal on a tree.
BinaryTreeNode
  
setLeft(obj:*):void
Writes data into the left child.
BinaryTreeNode
  
setRight(obj:*):void
Writes data into the right child.
BinaryTreeNode
  
toString():String
Prints out a string representing the current object.
BinaryTreeNode
Property Detail
dataproperty
public var data:*

The node's data.

leftproperty 
public var left:BinaryTreeNode

The left child node being referenced.

parentproperty 
public var parent:BinaryTreeNode

The parent node being referenced.

rightproperty 
public var right:BinaryTreeNode

The right child node being referenced.

Constructor Detail
BinaryTreeNode()Constructor
public function BinaryTreeNode(obj:*)

Creates an empty node.

Parameters
obj:* — The node's data.
Method Detail
count()method
public function count():int

Recursively counts the total number of nodes including this node.

Returns
int
destroy()method 
public function destroy():void

Recursively clears the tree by deleting all child nodes underneath the node the method is called on.

getDepth()method 
public function getDepth(node:BinaryTreeNode = null):int

Computes the depth of a tree.

Parameters

node:BinaryTreeNode (default = null)

Returns
int — The depth of the tree.
inorder()method 
public static function inorder(node:BinaryTreeNode, process:Function):void

Performs an inorder traversal on a tree. This processes the current node in between the child nodes.

Parameters

node:BinaryTreeNode — The node to start from.
 
process:Function — A process function applied to each traversed node.

isLeft()method 
public function isLeft():Boolean

Checks if the node is a left node relative to its parent node.

Returns
Boolean — True if this node is left, otherwise false.
isRight()method 
public function isRight():Boolean

Checks if the node is a right node relative to its parent node.

Returns
Boolean — True if this node is right, otherwise false.
postorder()method 
public static function postorder(node:BinaryTreeNode, process:Function):void

Performs a postorder traversal on a tree. This processes the current node after its children.

Parameters

node:BinaryTreeNode — The node to start from.
 
process:Function — A process function applied to each traversed node.

preorder()method 
public static function preorder(node:BinaryTreeNode, process:Function):void

Performs a preorder traversal on a tree. This processes the current tree node before its children.

Parameters

node:BinaryTreeNode — The node to start from.
 
process:Function — A process function applied to each traversed node.

setLeft()method 
public function setLeft(obj:*):void

Writes data into the left child.

Parameters

obj:* — The data.

setRight()method 
public function setRight(obj:*):void

Writes data into the right child.

Parameters

obj:* — The data.

toString()method 
public function toString():String

Prints out a string representing the current object.

Returns
String — A string representing the current object.