Class: BinaryTree

BinaryTree

new BinaryTree()

Source:

Methods

add(data, position) → {void}

Add node to tree
Parameters:
Name Type Description
data Number | String data to be added in tree
position Number add node provided position
Source:
Returns:
Type
void

children(position) → {Object}

return children of node
Parameters:
Name Type Description
position Object position of node
Source:
Returns:
return Iterator or list of children
Type
Object

elements() → {Object}

get all tree element starting from root
Source:
Returns:
Iterator
Type
Object

isEmpty() → {Boolean}

Tell tree is empty or not
Source:
Returns:
tree is empty ot not
Type
Boolean

isExternal(node) → {Boolean}

return node is external or not
Parameters:
Name Type Description
node Object node to check
Source:
Returns:
return true or false based on condition matched
Type
Boolean

isInternal(position) → {Boolean}

return node is internal or not
Parameters:
Name Type Description
position Object node is internal or not
Source:
Returns:
return node is internal or not
Type
Boolean

isRoot() → {Boolean}

return current node is root or not
Source:
Returns:
return node is root or not
Type
Boolean

isRoot(node) → {Boolean}

is node passed is root node or not
Parameters:
Name Type Description
node Object node to check
Source:
Returns:
return true/false based on condition
Type
Boolean

parent(position) → {Object}

return parent of passsed node
Parameters:
Name Type Description
position Object position of node
Source:
Returns:
return parent of node
Type
Object

positions() → {Object}

get all tree element starting from root
Source:
Returns:
Iterator
Type
Object

remove(position) → {Void}

remove node from tree
Parameters:
Name Type Description
position Number remove node from position
Source:
Returns:
Type
Void

replace(positionTo, positionFrom) → {void}

[replace description]
Parameters:
Name Type Description
positionTo Object replace to
positionFrom Object replace with
Source:
Returns:
Type
void

root(node) → {Object}

return root node of tree
Parameters:
Name Type Description
node Object node
Source:
Returns:
root node position
Type
Object

size() → {Number}

Show size of current tree
Source:
Returns:
return size of tree
Type
Number