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.
BinaryTreeNode | A binary tree node from which you can build a binary tree. |
Functions | |
preorder | Performs a preorder traversal on a tree. |
inorder | Performs an inorder traversal on a tree. |
postorder | Performs a postorder traversal on a tree. |
Variables | |
left | The left child node being referenced. |
right | The right child node being referenced. |
parent | The parent node being referenced. |
data | The node’s data. |
Functions | |
BinaryTreeNode | Creates an empty node. |
setLeft | Writes data into the left child. |
setRight | Writes data into the right child. |
isLeft | Checks if the node is a left node relative to its parent node. |
isRight | Checks if the node is a right node relative to its parent node. |
getDepth | Computes the depth of a tree. |
count | Recursively counts the total number of nodes including this node. |
destroy | Recursively clears the tree by deleting all child nodes underneath the node the method is called on. |
toString | Prints out a string representing the current object. |
Performs a preorder traversal on a tree.
public static function preorder( node: BinaryTreeNode, process: Function ):void
Performs an inorder traversal on a tree.
public static function inorder( node: BinaryTreeNode, process: Function ):void
Performs a postorder traversal on a tree.
public static function postorder( node: BinaryTreeNode, process: Function ):void
The left child node being referenced.
public var left: BinaryTreeNode
The right child node being referenced.
public var right: BinaryTreeNode
The parent node being referenced.
public var parent: BinaryTreeNode
The node’s data.
public var data: *
Creates an empty node.
public function BinaryTreeNode( obj: * )
Writes data into the left child.
public function setLeft( obj: * ):void
Writes data into the right child.
public function setRight( obj: * ):void
Checks if the node is a left node relative to its parent node.
public function isLeft():Boolean
Checks if the node is a right node relative to its parent node.
public function isRight():Boolean
Computes the depth of a tree.
public function getDepth( node: BinaryTreeNode = null ):int
Recursively counts the total number of nodes including this node.
public function count():int
Recursively clears the tree by deleting all child nodes underneath the node the method is called on.
public function destroy():void
Prints out a string representing the current object.
public function toString():String