Global

Methods

createNode(tree, parentKey, newContent)

Parameters:
Name Type Description
tree * tree to which node will be added
parentKey * key of parent of the new node
newContent * content of the new node
Source:
Returns:
the new node or null, if parent key not found in tree

createTree(rootcontent)

creates a tree object with one node: the root node
Parameters:
Name Type Description
rootcontent * the content of the new root node
Source:
Returns:
tree object consisting of root node

demoTree()

create a tree for test purposes (e.g. traversing) using addNode
Source:

insertNodeOver(tree, key, newContent)

Parameters:
Name Type Description
tree * tree to which node will be added
key * key of node where newNode will be inserted over
newContent * content of the new node
Source:
Returns:
the new node

randomKey(length) → {string}

Parameters:
Name Type Description
length * length of key to be generated
Source:
Returns:
- consists of chars randomly picked from 'characters'
Type
string

recurseNode(tree, currentNode, callbackEntering, callbackLeaving, level)

Code for traversing: https://code.tutsplus.com/articles/data-structures-with-javascript-tree--cms-23393
Parameters:
Name Type Description
tree * tree to be traversed
currentNode * current node while recursing
callbackEntering * callback function called before entering the current node
callbackLeaving * callback function called after leaving the current node
level * counts recursion level, may be used by callback functions
Source:

traverseLeafsToRoot(tree, callback)

Parameters:
Name Type Description
tree * keybased tree object
callback * function callbackLeaving(level, currentNode) called when leaving current node direction "leafs to root" is used by evaluating an arithmetic tree
Source:

traverseRootToLeafs(tree, callback)

Parameters:
Name Type Description
tree * keybased tree object
callback * function callbackEntering(level, currentNode) called when entering current node direction root to leafs ist used by displaying the tree in common manner
Source:

traverseRootToLeafs_EnterLeave(tree, callbackEnter, callbackLeave)

Parameters:
Name Type Description
tree * keybased tree object
callbackEnter * function callbackEnter(level, currentNode) called when entering current node
callbackLeave * function callbackLeave(level, currentNode) called when leaving current node
Source: