Abstract Protected constructorOptional options: AbstractBinaryTreeOptionsAn optional object that contains configuration options for the binary tree.
Private _autoPrivate _countPrivate _isPrivate _loopPrivate _maxPrivate _rootPrivate _sizePrivate _visitedPrivate _visitedPrivate _visitedPrivate _visitedPrivate _visitedThe BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.
an object of type AbstractBinaryTreeNodeProperties<N>.
The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.
The parameter nodeOrPropertyName is an optional parameter that
represents either a node or a property name. If a node is provided, the breadth-first search algorithm will be
performed starting from that node. If a property name is provided, the breadth-first search algorithm will be
performed starting from the root node
an object of type AbstractBinaryTreeNodeProperties<N>.
The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.
The parameter nodeOrPropertyName is an optional parameter that
represents either a node or a property name. If a node is provided, the breadth-first search algorithm will be
performed starting from that node. If a property name is provided, the breadth-first search algorithm will be
performed starting from the root node
an object of type AbstractBinaryTreeNodeProperties<N>.
The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.
The parameter nodeOrPropertyName is an optional parameter that
represents either a node or a property name. If a node is provided, the breadth-first search algorithm will be
performed starting from that node. If a property name is provided, the breadth-first search algorithm will be
performed starting from the root node
an object of type AbstractBinaryTreeNodeProperties<N>.
The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.
The parameter nodeOrPropertyName is an optional parameter that
represents either a node or a property name. If a node is provided, the breadth-first search algorithm will be
performed starting from that node. If a property name is provided, the breadth-first search algorithm will be
performed starting from the root node
an object of type AbstractBinaryTreeNodeProperties<N>.
The DFS function performs a depth-first search traversal on a binary tree and returns the results based on the specified pattern and node or property name.
an object of type AbstractBinaryTreeNodeProperties<N>.
The DFS function performs a depth-first search traversal on a binary tree and returns the results based on the specified pattern and node or property name.
Optional pattern: DFSOrderPatternThe "pattern" parameter is used to specify the order in which the nodes of a binary tree are traversed during the Depth-First Search (DFS) algorithm. It can take one of three values: 'in', 'pre', or 'post'.
Optional nodeOrPropertyName: "id"The nodeOrPropertyName parameter is a string that represents
either the name of a property in the BinaryTreeNode object or the value of the id property in the
BinaryTreeNode object. This parameter is used to accumulate the results based on the specified property name. If
no value
an object of type AbstractBinaryTreeNodeProperties<N>.
The DFS function performs a depth-first search traversal on a binary tree and returns the results based on the specified pattern and node or property name.
Optional pattern: DFSOrderPatternThe "pattern" parameter is used to specify the order in which the nodes of a binary tree are traversed during the Depth-First Search (DFS) algorithm. It can take one of three values: 'in', 'pre', or 'post'.
Optional nodeOrPropertyName: "val"The nodeOrPropertyName parameter is a string that represents
either the name of a property in the BinaryTreeNode object or the value of the id property in the
BinaryTreeNode object. This parameter is used to accumulate the results based on the specified property name. If
no value
an object of type AbstractBinaryTreeNodeProperties<N>.
The DFS function performs a depth-first search traversal on a binary tree and returns the results based on the specified pattern and node or property name.
Optional pattern: DFSOrderPatternThe "pattern" parameter is used to specify the order in which the nodes of a binary tree are traversed during the Depth-First Search (DFS) algorithm. It can take one of three values: 'in', 'pre', or 'post'.
Optional nodeOrPropertyName: "node"The nodeOrPropertyName parameter is a string that represents
either the name of a property in the BinaryTreeNode object or the value of the id property in the
BinaryTreeNode object. This parameter is used to accumulate the results based on the specified property name. If
no value
an object of type AbstractBinaryTreeNodeProperties<N>.
The DFS function performs a depth-first search traversal on a binary tree and returns the results based on the specified pattern and node or property name.
Optional pattern: DFSOrderPatternThe "pattern" parameter is used to specify the order in which the nodes of a binary tree are traversed during the Depth-First Search (DFS) algorithm. It can take one of three values: 'in', 'pre', or 'post'.
Optional nodeOrPropertyName: "count"The nodeOrPropertyName parameter is a string that represents
either the name of a property in the BinaryTreeNode object or the value of the id property in the
BinaryTreeNode object. This parameter is used to accumulate the results based on the specified property name. If
no value
an object of type AbstractBinaryTreeNodeProperties<N>.
Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack
Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack
Optional pattern: DFSOrderPatternOptional nodeOrPropertyName: "id"Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack
Optional pattern: DFSOrderPatternOptional nodeOrPropertyName: "val"Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack
Optional pattern: DFSOrderPatternOptional nodeOrPropertyName: "node"Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack
Optional pattern: DFSOrderPatternOptional nodeOrPropertyName: "count"Protected _accumulatedThe function _accumulatedByPropertyName pushes a property value of a binary tree node into an array based on the
provided property name or a default property name.
The node parameter is of type N, which represents a node in a binary tree.
Optional nodeOrPropertyName: NodeOrPropertyNameThe parameter nodeOrPropertyName is an optional parameter that
can be either a string representing a property name or a reference to a node object. If it is a string, it specifies
the property name of the node that should be accumulated. If it is a node object, it specifies the node itself
Protected _getThe function _getResultByPropertyName returns different results based on the provided property name or defaulting
to 'id'.
Optional nodeOrPropertyName: NodeOrPropertyNameThe parameter nodeOrPropertyName is an optional parameter that
can accept a value of type NodeOrPropertyName.
The method returns an object of type AbstractBinaryTreeNodeProperties<T>.
Protected _pushThe function checks if a given property of a binary tree node matches a specified value, and if so, adds the node to a result array.
The current binary tree node that is being checked.
An array that stores the matching nodes found during the traversal.
The nodeProperty parameter is the value that we are searching for in
the binary tree nodes. It can be either the id, count, or val property of the node.
Optional propertyName: BinaryTreeNodePropertyNameThe propertyName parameter is an optional parameter that
specifies the property of the BinaryTreeNode object that you want to compare with the nodeProperty value. It can
be one of the following values: 'id', 'count', or 'val'. If no propertyName is provided,
Optional onlyOne: booleanThe onlyOne parameter is an optional boolean parameter that determines whether to
stop after finding the first matching node or continue searching for all matching nodes. If onlyOne is set to
true, the function will stop after finding the first matching node and return true. If `onlyOne
a boolean value indicating whether or not a node was pushed into the result array.
Protected _resetProtected _setProtected _setProtected _setProtected _setProtected _setProtected _setProtected _setProtected _setProtected _setProtected _setProtected _setThe add function inserts a new node with a given ID and value into a binary tree, updating the count if the node
already exists.
The id parameter is the identifier of the binary tree node. It is used to uniquely identify each node in the binary tree.
Optional val: N["val"]The value to be inserted into the binary tree.
Optional count: numberThe count parameter is an optional parameter that specifies the number of times the
value should be inserted into the binary tree. If not provided, it defaults to 1.
The function add returns a N object if a new node is inserted, or null if no new node
is inserted, or undefined if the insertion fails.
The addMany function inserts multiple items into a binary tree and returns an array of the inserted nodes or
null/undefined values.
The data parameter can be either an array of elements of type N or an
array of N objects.
The function addMany returns an array of N, null, or undefined values.
The function adds a new node to a binary tree as the left or right child of a given parent node.
The newNode parameter represents the node that you want to add to the tree. It can be
either a node object (N) or null.
The parent parameter represents the parent node to which the new node will be added as a
child.
either the left or right child node that was added to the parent node. It can also return null or
undefined in certain cases.
Abstract createThe fill function clears the current data and inserts new data, returning a boolean indicating if the insertion
was successful.
The data parameter can be either an array of elements of type N or an
array of N objects.
The method is returning a boolean value.
The function returns the first binary tree node that matches the given property name and value, or null if no match is found.
The nodeProperty parameter can be either a BinaryTreeNodeId or a
generic type N. It represents the property of the binary tree node that you want to search for.
Optional propertyName: BinaryTreeNodePropertyNameThe propertyName parameter is an optional parameter that
specifies the property of the binary tree node to search for. If not provided, it defaults to 'id'.
a BinaryTreeNode object or null.
The function calculates the depth of a binary tree node by traversing its parent nodes.
N - This is the node for which we want to calculate the depth. It is a generic type, meaning it can represent any type of data that we want to store in the node.
The depth of the given binary tree node.
The getHeight function calculates the maximum height of a binary tree using either a recursive or iterative
approach.
Optional beginRoot: null | NThe beginRoot parameter is an optional parameter of type
N | null. It represents the starting node from which to calculate the height of the binary tree.
If no value is provided for beginRoot, the function will use the root property of the class instance as
the height of the binary tree.
The getLeftMost function returns the leftmost node in a binary tree, either recursively or iteratively using tail
recursion optimization.
The getLeftMost function returns the leftmost node in a binary tree.
The getLeftMost function returns the leftmost node in a binary tree, either recursively or iteratively using tail
recursion optimization.
The node parameter is an optional parameter of type N | null. It represents the starting node from which to find the leftmost node in a binary tree. If no node is
provided, the function will use the root node of the binary tree.
The getLeftMost function returns the leftmost node in a binary tree.
The getMinHeight function calculates the minimum height of a binary tree using either a recursive or iterative
approach.
Optional beginRoot: null | NThe beginRoot parameter is an optional parameter of type
N | null. It represents the starting node from which to calculate the minimum height of the binary
tree. If no value is provided for beginRoot, the function will use the root node of the binary tree.
The function getMinHeight returns the minimum height of the binary tree.
The function getNodes returns an array of binary tree nodes that match a given property value, with options for
searching recursively or iteratively.
The nodeProperty parameter can be either a BinaryTreeNodeId or a
generic type N. It represents the property of the binary tree node that you want to search for.
Optional propertyName: BinaryTreeNodePropertyNameThe propertyName parameter is an optional parameter that
specifies the property name to use when searching for nodes. If not provided, it defaults to 'id'.
Optional onlyOne: booleanThe onlyOne parameter is an optional boolean parameter that determines whether to
return only one node that matches the nodeProperty or propertyName criteria. If onlyOne is set to true, the
function will stop traversing the tree and return the first matching node. If @returns The functiongetNodesreturns an array ofN | null | undefined` objects.
The function getPathToRoot returns an array of BinaryTreeNode objects representing the path from a given node to the root of a binary tree.
The node parameter is a BinaryTreeNode object.
The function getPathToRoot returns an array of N objects, representing the path from
the given node to the root of the binary tree.
The getRightMost function returns the rightmost node in a binary tree, either recursively or iteratively using
tail recursion optimization.
The getRightMost function returns the rightmost node in a binary tree.
The getRightMost function returns the rightmost node in a binary tree, either recursively or iteratively using
tail recursion optimization.
The node parameter is an optional parameter of type N | null. It represents the starting node from which to find the rightmost node in a binary tree. If no node is
provided, the function will use the root node of the binary tree.
The getRightMost function returns the rightmost node in a binary tree.
The function calculates the size and count of a subtree in a binary tree using either recursive or iterative traversal.
The subTreeRoot parameter is the root node of a binary
tree.
The function getSubTreeSizeAndCount returns an array [number, number]. The first element of the array
represents the size of the subtree, and the second element represents the count of the nodes in the subtree.
The function checks if a binary tree node has a specific property or if any node in the tree has a specific property.
The nodeProperty parameter can be either a BinaryTreeNodeId or a
generic type N. It represents the property of a binary tree node that you want to check.
Optional propertyName: BinaryTreeNodePropertyNameThe propertyName parameter is an optional parameter that
specifies the name of the property to check for in the nodes.
a boolean value.
The function checks if a binary tree is balanced by comparing the minimum height and the maximum height of the tree.
Optional beginRoot: null | NThe beginRoot parameter is the root node of a binary tree. It is
of type N | null, which means it can either be a BinaryTreeNode object or null.
The method is returning a boolean value.
The levelIterative function performs a level-order traversal on a binary tree and returns the values of the nodes
in an array, based on a specified property name.
The node parameter is a BinaryTreeNode object representing the starting
node for the level order traversal. It can be null if no specific node is provided, in which case the root node of
the tree is used as the starting node.
The function levelIterative returns an object of type AbstractBinaryTreeNodeProperties<N>.
The levelIterative function performs a level-order traversal on a binary tree and returns the values of the nodes
in an array, based on a specified property name.
The node parameter is a BinaryTreeNode object representing the starting
node for the level order traversal. It can be null if no specific node is provided, in which case the root node of
the tree is used as the starting node.
Optional nodeOrPropertyName: "id"The nodeOrPropertyName parameter is an optional parameter that
can be either a BinaryTreeNode property name or the string 'id'. If a property name is provided, the function
will accumulate results based on that property. If no property name is provided, the function will default to
accumulating results
The function levelIterative returns an object of type AbstractBinaryTreeNodeProperties<N>.
The levelIterative function performs a level-order traversal on a binary tree and returns the values of the nodes
in an array, based on a specified property name.
The node parameter is a BinaryTreeNode object representing the starting
node for the level order traversal. It can be null if no specific node is provided, in which case the root node of
the tree is used as the starting node.
Optional nodeOrPropertyName: "val"The nodeOrPropertyName parameter is an optional parameter that
can be either a BinaryTreeNode property name or the string 'id'. If a property name is provided, the function
will accumulate results based on that property. If no property name is provided, the function will default to
accumulating results
The function levelIterative returns an object of type AbstractBinaryTreeNodeProperties<N>.
The levelIterative function performs a level-order traversal on a binary tree and returns the values of the nodes
in an array, based on a specified property name.
The node parameter is a BinaryTreeNode object representing the starting
node for the level order traversal. It can be null if no specific node is provided, in which case the root node of
the tree is used as the starting node.
Optional nodeOrPropertyName: "node"The nodeOrPropertyName parameter is an optional parameter that
can be either a BinaryTreeNode property name or the string 'id'. If a property name is provided, the function
will accumulate results based on that property. If no property name is provided, the function will default to
accumulating results
The function levelIterative returns an object of type AbstractBinaryTreeNodeProperties<N>.
The levelIterative function performs a level-order traversal on a binary tree and returns the values of the nodes
in an array, based on a specified property name.
The node parameter is a BinaryTreeNode object representing the starting
node for the level order traversal. It can be null if no specific node is provided, in which case the root node of
the tree is used as the starting node.
Optional nodeOrPropertyName: "count"The nodeOrPropertyName parameter is an optional parameter that
can be either a BinaryTreeNode property name or the string 'id'. If a property name is provided, the function
will accumulate results based on that property. If no property name is provided, the function will default to
accumulating results
The function levelIterative returns an object of type AbstractBinaryTreeNodeProperties<N>.
The listLevels function collects nodes from a binary tree by a specified property and organizes them into levels.
The node parameter is a BinaryTreeNode object or null. It represents the
root node of a binary tree. If it is null, the function will use the root node of the current binary tree instance.
The function listLevels returns a 2D array of AbstractBinaryTreeNodeProperty<N> objects.
The listLevels function collects nodes from a binary tree by a specified property and organizes them into levels.
The node parameter is a BinaryTreeNode object or null. It represents the
root node of a binary tree. If it is null, the function will use the root node of the current binary tree instance.
Optional nodeOrPropertyName: "id"The nodeOrPropertyName parameter is an optional parameter that
specifies the property of the BinaryTreeNode object to collect at each level. It can be one of the following
values:
The function listLevels returns a 2D array of AbstractBinaryTreeNodeProperty<N> objects.
The listLevels function collects nodes from a binary tree by a specified property and organizes them into levels.
The node parameter is a BinaryTreeNode object or null. It represents the
root node of a binary tree. If it is null, the function will use the root node of the current binary tree instance.
Optional nodeOrPropertyName: "val"The nodeOrPropertyName parameter is an optional parameter that
specifies the property of the BinaryTreeNode object to collect at each level. It can be one of the following
values:
The function listLevels returns a 2D array of AbstractBinaryTreeNodeProperty<N> objects.
The listLevels function collects nodes from a binary tree by a specified property and organizes them into levels.
The node parameter is a BinaryTreeNode object or null. It represents the
root node of a binary tree. If it is null, the function will use the root node of the current binary tree instance.
Optional nodeOrPropertyName: "node"The nodeOrPropertyName parameter is an optional parameter that
specifies the property of the BinaryTreeNode object to collect at each level. It can be one of the following
values:
The function listLevels returns a 2D array of AbstractBinaryTreeNodeProperty<N> objects.
The listLevels function collects nodes from a binary tree by a specified property and organizes them into levels.
The node parameter is a BinaryTreeNode object or null. It represents the
root node of a binary tree. If it is null, the function will use the root node of the current binary tree instance.
Optional nodeOrPropertyName: "count"The nodeOrPropertyName parameter is an optional parameter that
specifies the property of the BinaryTreeNode object to collect at each level. It can be one of the following
values:
The function listLevels returns a 2D array of AbstractBinaryTreeNodeProperty<N> objects.
The morris function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris
traversal algorithm and returns the results based on the specified property name.
The time complexity of Morris traversal is O(n), it's may slower than others
The space complexity Morris traversal is O(1) because no using stack
The function morris returns an object of type AbstractBinaryTreeNodeProperties<N>.
The morris function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris
traversal algorithm and returns the results based on the specified property name.
The time complexity of Morris traversal is O(n), it's may slower than others
The space complexity Morris traversal is O(1) because no using stack
Optional pattern: DFSOrderPatternThe pattern parameter is an optional parameter that determines the
traversal pattern of the binary tree. It can have one of three values:
Optional nodeOrPropertyName: "id"The nodeOrPropertyName parameter is used to specify the
property of the nodes that you want to retrieve in the results. It can be either the node itself or the name of the
property. If not provided, it defaults to 'id'.
The function morris returns an object of type AbstractBinaryTreeNodeProperties<N>.
The morris function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris
traversal algorithm and returns the results based on the specified property name.
The time complexity of Morris traversal is O(n), it's may slower than others
The space complexity Morris traversal is O(1) because no using stack
Optional pattern: DFSOrderPatternThe pattern parameter is an optional parameter that determines the
traversal pattern of the binary tree. It can have one of three values:
Optional nodeOrPropertyName: "val"The nodeOrPropertyName parameter is used to specify the
property of the nodes that you want to retrieve in the results. It can be either the node itself or the name of the
property. If not provided, it defaults to 'id'.
The function morris returns an object of type AbstractBinaryTreeNodeProperties<N>.
The morris function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris
traversal algorithm and returns the results based on the specified property name.
The time complexity of Morris traversal is O(n), it's may slower than others
The space complexity Morris traversal is O(1) because no using stack
Optional pattern: DFSOrderPatternThe pattern parameter is an optional parameter that determines the
traversal pattern of the binary tree. It can have one of three values:
Optional nodeOrPropertyName: "node"The nodeOrPropertyName parameter is used to specify the
property of the nodes that you want to retrieve in the results. It can be either the node itself or the name of the
property. If not provided, it defaults to 'id'.
The function morris returns an object of type AbstractBinaryTreeNodeProperties<N>.
The morris function performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris
traversal algorithm and returns the results based on the specified property name.
The time complexity of Morris traversal is O(n), it's may slower than others
The space complexity Morris traversal is O(1) because no using stack
Optional pattern: DFSOrderPatternThe pattern parameter is an optional parameter that determines the
traversal pattern of the binary tree. It can have one of three values:
Optional nodeOrPropertyName: "count"The nodeOrPropertyName parameter is used to specify the
property of the nodes that you want to retrieve in the results. It can be either the node itself or the name of the
property. If not provided, it defaults to 'id'.
The function morris returns an object of type AbstractBinaryTreeNodeProperties<N>.
The function removes a node from a binary tree and returns information about the deleted node.
The id parameter is the identifier of the binary tree node that you want to remove.
It is of type BinaryTreeNodeId.
Optional ignoreCount: booleanThe ignoreCount parameter is an optional boolean parameter that determines
whether to ignore the count of the node being removed. If ignoreCount is set to true, the count of the node will
not be decremented and the overall count of the binary tree will not be updated. If `
An array of objects is being returned. Each object in the array has two properties: "deleted" and "needBalanced". The "deleted" property contains the deleted node or undefined if no node was deleted. The "needBalanced" property is always null.
Protected setThe function subTreeAdd adds a specified delta value to a property of each node in a binary tree.
The subTreeRoot parameter is the root node of the subtree where the values will be modified.
The delta parameter is a number that represents the amount by which the property value of
each node in the subtree should be increased or decreased.
Optional propertyName: BinaryTreeNodePropertyNameThe propertyName parameter is an optional parameter that
specifies the property of the BinaryTreeNode that should be modified. It defaults to 'id' if not provided.
a boolean value, which is true.
The function subTreeSum calculates the sum of a specified property in a binary tree, either recursively or
iteratively.
The subTreeRoot parameter is the root node of the subtree for which you want to calculate the sum.
Optional propertyName: BinaryTreeNodePropertyNameThe propertyName parameter is an optional parameter that
specifies the property of the BinaryTreeNode object to use for calculating the sum. If propertyName is not
provided, it defaults to 'val'.
a number, which is the sum of the values of the nodes in the subtree rooted at subTreeRoot.
Generated using TypeDoc
The protected constructor initializes the options for an abstract binary tree.