Class: BinaryNode

BinaryNode(left, right, data)

A basic unit of data with pointers to two other nodes

Constructor

new BinaryNode(left, right, data)

Construct a binary tree object
Parameters:
Name Type Description
left BinaryNode Pointer to the "left" node
right BinaryNode Pointer to the "right" node
data * The data that this node will hold
Source:

Members

data

The data that this node will hold
Source:

left

Pointer to the "left" node
Source:
Pointer to the "right" node
Source:

Methods

searchTreeInsert(value, comparator, node) → {boolean}

Attempt to insert a value
Parameters:
Name Type Description
value * The value to insert
comparator function The comparator(val1, val2) function that will be used to compare two values, defaults to aritmetic comparator if undefined
node BinaryNode The node being evaluated, defaults to this.root if undefined
Source:
Returns:
whether or not the value was successfully inserted
Type
boolean

toArray() → {Array}

Return this tree as an array of it's values, will be sorted if the tree is a bst
Source:
Returns:
this tree as a sorted array of values
Type
Array