# TreeMultiset | data-structure-typed
Documentation for data-structure-typed

# Class TreeMultiset<N>

The only distinction between a TreeMultiset and a AVLTree lies in the ability of the former to store duplicate nodes through the utilization of counters.

#### Type Parameters

- #### N extends TreeMultisetNode <N["val"], N> = TreeMultisetNode

#### Hierarchy

- AVLTree <N>
  - TreeMultiset

#### Implements

- ITreeMultiset <N>

- Defined in src/data-structures/binary-tree/tree-multiset.ts:46

#####
Index

### Constructors

constructor

### Properties

_comparator
_count

### Accessors

count
loopType
root
size
visitedId
visitedLeftSum
visitedNode
visitedVal

### Methods

BFS
BFSCount
DFS
DFSCount
DFSIterative
DFSIterativeCount
_accumulatedByPropertyName
_addTo
_balanceFactor
_balanceLL
_balanceLR
_balancePath
_balanceRL
_balanceRR
_clearResults
_compare
_getResultByPropertyName
_pushByPropertyNameStopOrNot
_setCount
_setLoopType
_setRoot
_setSize
_setVisitedId
_setVisitedLeftSum
_setVisitedNode
_setVisitedVal
_updateHeight
add
addMany
allGreaterNodesAdd
allGreaterNodesAddCount
clear
createNode
fill
get
getDepth
getHeight
getLeftMost
getMinHeight
getNodes
getNodesByCount
getPathToRoot
getPredecessor
getRightMost
getSubTreeCount
getSubTreeSize
has
isAVLBalanced
isBST
isEmpty
isPerfectlyBalanced
isSubtreeBST
lastKey
lesserSum
lesserSumCount
levelIterative
listLevels
listLevelsCount
morris
morrisCount
perfectlyBalance
remove
subTreeAdd
subTreeAddCount
subTreeSum
subTreeSumCount
swapLocation

## Constructors

### constructor

- new TreeMultiset<N>(options?): TreeMultiset <N>

- The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to merge duplicated values.

  #### Type Parameters

  - #### N extends TreeMultisetNode <N["val"], N, N> = TreeMultisetNode <any, TreeMultisetNodeNested <any>>

  #### Parameters

  - ##### `Optional` options: Omit< AVLTreeOptions , "isMergeDuplicatedNodeById">

    An optional object that contains additional configuration options for the TreeMultiset.

  #### Returns TreeMultiset <N>

  Overrides AVLTree.constructor

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:56

## Properties

### `Protected` _comparator

_comparator: BSTComparator = ...

Inherited from AVLTree._comparator

- Defined in src/data-structures/binary-tree/bst.ts:519

### `Private` _count

_count: number = 0

- Defined in src/data-structures/binary-tree/tree-multiset.ts:60

## Accessors

### count

- get count(): number

- #### Returns number

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:62

### loopType

- get loopType(): LoopType

- #### Returns LoopType

  Implementation of ITreeMultiset.loopType

  Inherited from AVLTree.loopType

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:168

### root

- get root(): null | N

- #### Returns null | N

  Implementation of ITreeMultiset.root

  Inherited from AVLTree.root

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:156

### size

- get size(): number

- #### Returns number

  Implementation of ITreeMultiset.size

  Inherited from AVLTree.size

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:162

### visitedId

- get visitedId(): number[]

- #### Returns number[]

  Implementation of ITreeMultiset.visitedId

  Inherited from AVLTree.visitedId

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:174

### visitedLeftSum

- get visitedLeftSum(): number[]

- #### Returns number[]

  Implementation of ITreeMultiset.visitedLeftSum

  Inherited from AVLTree.visitedLeftSum

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:192

### visitedNode

- get visitedNode(): N[]

- #### Returns N[]

  Implementation of ITreeMultiset.visitedNode

  Inherited from AVLTree.visitedNode

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:186

### visitedVal

- get visitedVal(): N["val"][]

- #### Returns N["val"][]

  Implementation of ITreeMultiset.visitedVal

  Inherited from AVLTree.visitedVal

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:180

## Methods

### BFS

- BFS(): number[]

- Performs a breadth-first search (BFS) on a binary tree, accumulating properties of each node based on their 'id' property.

  #### Returns number[]

  An array of binary tree node IDs.

  Implementation of ITreeMultiset.BFS

  Inherited from AVLTree.BFS

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:929
- BFS(nodeOrPropertyName): number[]

- Performs a breadth-first search (BFS) on a binary tree, accumulating properties of each node based on the specified property name.

  #### Parameters

  - ##### nodeOrPropertyName: "id"

    The name of the property to accumulate.

  #### Returns number[]

  An array of values corresponding to the specified property.

  Implementation of ITreeMultiset.BFS

  Inherited from AVLTree.BFS

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:936
- BFS(nodeOrPropertyName): N["val"][]

- Performs a breadth-first search (BFS) on a binary tree, accumulating the 'val' property of each node.

  #### Parameters

  - ##### nodeOrPropertyName: "val"

    The name of the property to accumulate.

  #### Returns N["val"][]

  An array of 'val' properties from each node.

  Implementation of ITreeMultiset.BFS

  Inherited from AVLTree.BFS

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:943
- BFS(nodeOrPropertyName): N[]

- Performs a breadth-first search (BFS) on a binary tree, accumulating nodes themselves.

  #### Parameters

  - ##### nodeOrPropertyName: "node"

    The name of the property to accumulate.

  #### Returns N[]

  An array of binary tree nodes.

  Implementation of ITreeMultiset.BFS

  Inherited from AVLTree.BFS

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:950

### BFSCount

- BFSCount(): number[]

- The BFSCount function returns an array of counts from a breadth-first search of nodes.

  #### Returns number[]

  The BFSCount() function returns an array of numbers, specifically the count property of each node in the BFS traversal.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:527

### DFS

- DFS(): number[]

- Performs a depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on their 'id' property.

  #### Returns number[]

  An array of binary tree node IDs.

  Implementation of ITreeMultiset.DFS

  Inherited from AVLTree.DFS

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:980
- DFS(pattern?, nodeOrPropertyName?): number[]

- Performs a depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on the specified property name.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "id"

    The name of the property to accumulate.

  #### Returns number[]

  An array of values corresponding to the specified property.

  Implementation of ITreeMultiset.DFS

  Inherited from AVLTree.DFS

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:988
- DFS(pattern?, nodeOrPropertyName?): N[]

- Performs a depth-first search (DFS) traversal on a binary tree and accumulates the 'val' property of each node.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "val"

    The name of the property to accumulate.

  #### Returns N[]

  An array of 'val' properties from each node.

  Implementation of ITreeMultiset.DFS

  Inherited from AVLTree.DFS

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:996
- DFS(pattern?, nodeOrPropertyName?): N[]

- Performs a depth-first search (DFS) traversal on a binary tree and accumulates nodes themselves.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "node"

    The name of the property to accumulate.

  #### Returns N[]

  An array of binary tree nodes.

  Implementation of ITreeMultiset.DFS

  Inherited from AVLTree.DFS

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1004

### DFSCount

- DFSCount(pattern?): number[]

- The DFSCount function returns an array of counts for each node in a depth-first search traversal.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The pattern parameter is an optional parameter that specifies the order in which the Depth-First Search (DFS) algorithm should traverse the nodes. It can have one of the following values:

  #### Returns number[]

  The DFSCount function returns an array of numbers, specifically the count property of each node in the DFS traversal.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:579

### DFSIterative

- DFSIterative(): number[]

- Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on their 'id' property.

  #### Returns number[]

  An array of binary tree node IDs.

  Implementation of ITreeMultiset.DFSIterative

  Inherited from AVLTree.DFSIterative

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1047
- DFSIterative(pattern?, nodeOrPropertyName?): number[]

- Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates properties of each node based on the specified property name.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "id"

    The name of the property to accumulate.

  #### Returns number[]

  An array of values corresponding to the specified property.

  Implementation of ITreeMultiset.DFSIterative

  Inherited from AVLTree.DFSIterative

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1055
- DFSIterative(pattern?, nodeOrPropertyName?): N[]

- Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates the 'val' property of each node.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "val"

    The name of the property to accumulate.

  #### Returns N[]

  An array of 'val' properties from each node.

  Implementation of ITreeMultiset.DFSIterative

  Inherited from AVLTree.DFSIterative

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1063
- DFSIterative(pattern?, nodeOrPropertyName?): N[]

- Performs an iterative depth-first search (DFS) traversal on a binary tree and accumulates nodes themselves.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "node"

    The name of the property to accumulate.

  #### Returns N[]

  An array of binary tree nodes.

  Implementation of ITreeMultiset.DFSIterative

  Inherited from AVLTree.DFSIterative

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1071

### DFSIterativeCount

- DFSIterativeCount(pattern?): number[]

- The function DFSIterativeCount performs an iterative depth-first search and returns an array of node counts based on the specified traversal pattern.

  #### Parameters

  - ##### `Optional` pattern: "in" | "pre" | "post"

    The pattern parameter is a string that specifies the traversal order for the Depth-First Search (DFS) algorithm. It can have three possible values: 'in', 'pre', or 'post'.

  #### Returns number[]

  The DFSIterativeCount function returns an array of numbers, which represents the count property of each node in the DFS traversal.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:566

### `Protected` _accumulatedByPropertyName

- _accumulatedByPropertyName(node, nodeOrPropertyName?): void

- The function `_accumulatedByPropertyName` accumulates values from a given node based on the specified property name.

  #### Parameters

  - ##### node: N

    The `node` parameter is of type `N`, which represents a node in a data structure.

  - ##### `Optional` nodeOrPropertyName: NodeOrPropertyName

    The `nodeOrPropertyName` parameter 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 to be used for accumulating values. If it is a `Node` object, it specifies

  #### Returns void

  Inherited from AVLTree._accumulatedByPropertyName

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1584

### _addTo

- _addTo(newNode, parent): undefined | null | N

- The function adds a new node to a binary tree if there is an available slot on the left or right side of the parent node.

  #### Parameters

  - ##### newNode: null | N

    The `newNode` parameter represents the node that needs to be added to the tree. It can be either a node object (`N`) or `null`.

  - ##### parent: N

    The `parent` parameter represents the parent node to which the new node will be added as a child.

  #### Returns undefined | null | N

  The method returns either the `parent.left`, `parent.right`, or `undefined`.

  Overrides AVLTree._addTo

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:194

### `Protected` _balanceFactor

- _balanceFactor(node): number

- The balance factor of a given AVL tree node is calculated by subtracting the height of its left subtree from the height of its right subtree.

  #### Parameters

  - ##### node: N

    The parameter "node" is of type N, which represents a node in an AVL tree.

  #### Returns number

  The balance factor of the given AVL tree node.

  Inherited from AVLTree._balanceFactor

  - Defined in src/data-structures/binary-tree/avl-tree.ts:84

### `Protected` _balanceLL

- _balanceLL(A): void

- The `_balanceLL` function performs a left-left rotation on an AVL tree to balance it.

  #### Parameters

  - ##### A: N

    The parameter A is an AVLTreeNode object.

  #### Returns void

  Inherited from AVLTree._balanceLL

  - Defined in src/data-structures/binary-tree/avl-tree.ts:155

### `Protected` _balanceLR

- _balanceLR(A): void

- The `_balanceLR` function performs a left-right rotation to balance an AVL tree.

  #### Parameters

  - ##### A: N

    A is an AVLTreeNode object.

  #### Returns void

  Inherited from AVLTree._balanceLR

  - Defined in src/data-structures/binary-tree/avl-tree.ts:185

### `Protected` _balancePath

- _balancePath(node): void

- The `_balancePath` function balances the AVL tree by performing appropriate rotations based on the balance factor of each node in the path from the given node to the root.

  #### Parameters

  - ##### node: N

    The `node` parameter is an AVLTreeNode object, which represents a node in an AVL tree.

  #### Returns void

  Inherited from AVLTree._balancePath

  - Defined in src/data-structures/binary-tree/avl-tree.ts:112

### `Protected` _balanceRL

- _balanceRL(A): void

- The `_balanceRL` function performs a right-left rotation to balance an AVL tree.

  #### Parameters

  - ##### A: N

    A is an AVLTreeNode object.

  #### Returns void

  Inherited from AVLTree._balanceRL

  - Defined in src/data-structures/binary-tree/avl-tree.ts:268

### `Protected` _balanceRR

- _balanceRR(A): void

- The `_balanceRR` function performs a right-right rotation on an AVL tree to balance it.

  #### Parameters

  - ##### A: N

    The parameter A is an AVLTreeNode object.

  #### Returns void

  Inherited from AVLTree._balanceRR

  - Defined in src/data-structures/binary-tree/avl-tree.ts:233

### `Protected` _clearResults

- _clearResults(): void

- The function `_clearResults` resets the values of several arrays used for tracking visited nodes and their properties.

  #### Returns void

  Inherited from AVLTree._clearResults

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1526

### `Protected` _compare

- _compare(a, b): CP

- The function compares two binary tree node IDs using a comparator function and returns whether the first ID is greater than, less than, or equal to the second ID.

  #### Parameters

  - ##### a: number

    a is a BinaryTreeNodeId, which represents the identifier of a binary tree node.

  - ##### b: number

    The parameter "b" in the above code refers to a BinaryTreeNodeId.

  #### Returns CP

  a value of type CP (ComparisonResult). The possible return values are CP.gt (greater than), CP.lt (less than), or CP.eq (equal).

  Inherited from AVLTree._compare

  - Defined in src/data-structures/binary-tree/bst.ts:529

### `Protected` _getResultByPropertyName

- _getResultByPropertyName(nodeOrPropertyName?): AbstractBinaryTreeNodeProperties <N>

- The function `_getResultByPropertyName` returns the corresponding property value based on the given node or property name.

  #### Parameters

  - ##### `Optional` nodeOrPropertyName: NodeOrPropertyName

    The parameter `nodeOrPropertyName` is an optional parameter that can accept either a `NodeOrPropertyName` type or be undefined.

  #### Returns AbstractBinaryTreeNodeProperties <N>

  The method `_getResultByPropertyName` returns an instance of `AbstractBinaryTreeNodeProperties<N>`.

  Inherited from AVLTree._getResultByPropertyName

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1615

### `Protected` _pushByPropertyNameStopOrNot

- _pushByPropertyNameStopOrNot(cur, result, nodeProperty, propertyName?, onlyOne?): undefined | boolean

- The 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.

  #### Parameters

  - ##### cur: N

    The current node being processed.

  - ##### result: (undefined | null | N)[]

    An array that stores the matching nodes.

  - ##### nodeProperty: number | N

    The `nodeProperty` parameter is either a `BinaryTreeNodeId` or a `N` type. It represents the property value that we are comparing against in the switch statement.

  - ##### `Optional` propertyName: BinaryTreeNodePropertyName

    The `propertyName` parameter is an optional parameter that specifies the property name to compare against when pushing nodes into the `result` array. It can be either `'id'` or `'val'`. If it is not provided or is not equal to `'id'` or `'val'`, the

  - ##### `Optional` onlyOne: boolean

    The `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

  #### Returns undefined | boolean

  a boolean value indicating whether only one matching node should be pushed into the result array.

  Inherited from AVLTree._pushByPropertyNameStopOrNot

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1548

### `Protected` _setCount

- _setCount(v): void

- The function "_setCount" is used to set the value of the "_count" property.

  #### Parameters

  - ##### v: number

    number

  #### Returns void

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:697

### `Protected` _setLoopType

- _setLoopType(value): void

- The function sets the loop type for a protected variable.

  #### Parameters

  - ##### value: LoopType

    The value parameter is of type LoopType.

  #### Returns void

  Inherited from AVLTree._setLoopType

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1466

### `Protected` _setRoot

- _setRoot(v): void

- The function sets the root property of an object to a given value, and if the value is not null, it also sets the parent property of the value to undefined.

  #### Parameters

  - ##### v: null | N

    The parameter `v` is of type `N | null`, which means it can either be of type `N` or `null`.

  #### Returns void

  Inherited from AVLTree._setRoot

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1507

### `Protected` _setSize

- _setSize(v): void

- The function sets the size of a protected variable.

  #### Parameters

  - ##### v: number

    number

  #### Returns void

  Inherited from AVLTree._setSize

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1518

### `Protected` _setVisitedId

- _setVisitedId(value): void

- The function sets the value of the `_visitedId` property in a protected manner.

  #### Parameters

  - ##### value: number[]

    value is an array of BinaryTreeNodeId values.

  #### Returns void

  Inherited from AVLTree._setVisitedId

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1474

### `Protected` _setVisitedLeftSum

- _setVisitedLeftSum(value): void

- The function sets the value of the `_visitedLeftSum` property to the provided array.

  #### Parameters

  - ##### value: number[]

    An array of numbers that represents the visited left sum.

  #### Returns void

  Inherited from AVLTree._setVisitedLeftSum

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1498

### `Protected` _setVisitedNode

- _setVisitedNode(value): void

- The function sets the value of the _visitedNode property.

  #### Parameters

  - ##### value: N[]

    N[] is an array of elements of type N.

  #### Returns void

  Inherited from AVLTree._setVisitedNode

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1490

### `Protected` _setVisitedVal

- _setVisitedVal(value): void

- The function sets the value of the "_visitedVal" property to the given array.

  #### Parameters

  - ##### value: N[]

    An array of type N.

  #### Returns void

  Inherited from AVLTree._setVisitedVal

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1482

### `Protected` _updateHeight

- _updateHeight(node): void

- The function updates the height of a node in an AVL tree based on the heights of its left and right subtrees.

  #### Parameters

  - ##### node: N

    The parameter `node` is an AVLTreeNode object, which represents a node in an AVL tree.

  #### Returns void

  Inherited from AVLTree._updateHeight

  - Defined in src/data-structures/binary-tree/avl-tree.ts:98

### add

- add(idOrNode, val?, count?): undefined | null | N

- The `add` function adds a new node to a binary search tree, maintaining the tree's properties and balancing if necessary.

  #### Parameters

  - ##### idOrNode: null | number | N

    The `idOrNode` parameter can be either a `BinaryTreeNodeId` or a `N` (which represents a `BinaryTreeNode`).

  - ##### `Optional` val: N["val"]

    The `val` parameter represents the value to be added to the binary tree node.

  - ##### `Optional` count: number

    The `count` parameter is an optional parameter that specifies the number of times the value should be added to the binary tree. If the `count` parameter is not provided, it defaults to 1.

  #### Returns undefined | null | N

  The method `add` returns either the inserted node (`N`), `null`, or `undefined`.

  Implementation of ITreeMultiset.add

  Overrides AVLTree.add

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:116

### addMany

- addMany(idsOrNodes, data?): (undefined | null | N)[]

- The `addMany` function takes an array of node IDs or nodes and adds them to the tree multiset, returning an array of the inserted nodes.

  #### Parameters

  - ##### idsOrNodes: (null | number)[] | (null | N)[]

    An array of BinaryTreeNodeId or BinaryTreeNode objects, or null values.

  - ##### `Optional` data: N["val"][]

    The `data` parameter is an optional array of values (`N['val'][]`) that corresponds to the nodes being added. It is used when adding nodes using the `idOrNode` and `data` arguments in the `this.add()` method. If provided, the `data` array should

  #### Returns (undefined | null | N)[]

  The function `addMany` returns an array of `N`, `null`, or `undefined` values.

  Implementation of ITreeMultiset.addMany

  Overrides AVLTree.addMany

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:229

### allGreaterNodesAdd

- allGreaterNodesAdd(node, delta, propertyName?): boolean

- The `allGreaterNodesAdd` function adds a delta value to the specified property of all nodes in a binary tree that have a greater value than a given node.

  #### Parameters

  - ##### node: null | number | N

    The `node` parameter can be either of type `N` (a generic type), `BinaryTreeNodeId`, or `null`. It represents the node in the binary tree to which the delta value will be added.

  - ##### delta: number

    The `delta` parameter is a number that represents the amount by which the property value of each greater node should be increased.

  - ##### `Optional` propertyName: BinaryTreeNodePropertyName

    The `propertyName` parameter is an optional parameter that specifies the property name of the nodes in the binary tree that you want to update. If not provided, it defaults to 'id'.

  #### Returns boolean

  a boolean value.

  Implementation of ITreeMultiset.allGreaterNodesAdd

  Inherited from AVLTree.allGreaterNodesAdd

  - Defined in src/data-structures/binary-tree/bst.ts:370

### allGreaterNodesAddCount

- allGreaterNodesAddCount(node, delta): boolean

- The function `allGreaterNodesAddCount` updates the count property of all nodes in a binary tree that have an ID greater than a given ID by a specified delta value.

  #### Parameters

  - ##### node: null | number | N

    The `node` parameter can be one of the following:

  - ##### delta: number

    The `delta` parameter is a number that represents the amount by which the `count` property of each node should be increased.

  #### Returns boolean

  a boolean value.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:651

### clear

- clear(): void

- The clear() function clears the data and sets the count to 0.

  #### Returns void

  Implementation of ITreeMultiset.clear

  Overrides AVLTree.clear

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:688

### createNode

- createNode(id, val?, count?): N

- The function creates a new BSTNode with the given id, value, and count.

  #### Parameters

  - ##### id: number

    The id parameter is the unique identifier for the binary tree node. It is used to distinguish one node from another in the tree.

  - ##### `Optional` val: N["val"]

    The `val` parameter represents the value that will be stored in the binary search tree node.

  - ##### `Optional` count: number

    The "count" parameter is an optional parameter of type number. It represents the number of occurrences of the value in the binary search tree node. If not provided, the count will default to 1.

  #### Returns N

  A new instance of the BSTNode class with the specified id, value, and count (if provided).

  Implementation of ITreeMultiset.createNode

  Overrides AVLTree.createNode

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:75

### fill

- fill(idsOrNodes, data?): boolean

- The `fill` function clears the binary tree and adds multiple nodes with the given IDs or nodes and optional data.

  #### Parameters

  - ##### idsOrNodes: (null | number)[] | (null | N)[]

    The `idsOrNodes` parameter is an array that can contain either `BinaryTreeNodeId` or `N` values.

  - ##### `Optional` data: N["val"][] | N[]

    The `data` parameter is an optional array of values that will be assigned to the nodes being added. If provided, the length of the `data` array should be equal to the length of the `idsOrNodes` array. Each value in the `data` array will be assigned to the

  #### Returns boolean

  The method is returning a boolean value.

  Implementation of ITreeMultiset.fill

  Inherited from AVLTree.fill

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:345

### get

- get(nodeProperty, propertyName?): null | N

- The function returns the first node in a binary tree that matches the given property name and value.

  #### Parameters

  - ##### nodeProperty: number | N

    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: BinaryTreeNodePropertyName

    The `propertyName` parameter is an optional parameter that specifies the property name to use for searching the binary tree nodes. If not provided, it defaults to `'id'`.

  #### Returns null | N

  The method is returning either a BinaryTreeNodeId or N (generic type) or null.

  Implementation of ITreeMultiset.get

  Inherited from AVLTree.get

  - Defined in src/data-structures/binary-tree/bst.ts:211

### getDepth

- getDepth(beginRoot): number

- The function calculates the depth of a node in a binary tree.

  #### Parameters

  - ##### beginRoot: null | number | N

    The `beginRoot` parameter can be one of the following:

  #### Returns number

  the depth of the given node or binary tree.

  Implementation of ITreeMultiset.getDepth

  Inherited from AVLTree.getDepth

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:412

### getHeight

- getHeight(beginRoot?): number

- The `getHeight` function calculates the maximum height of a binary tree, either recursively or iteratively.

  #### Parameters

  - ##### `Optional` beginRoot: null | number | N

    The `beginRoot` parameter is optional and can be of type `N` (a generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree node), or `null`.

  #### Returns number

  the height of the binary tree.

  Implementation of ITreeMultiset.getHeight

  Inherited from AVLTree.getHeight

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:430

### getLeftMost

- getLeftMost(): null | N

- The function `getLeftMost` returns the leftmost node in a binary tree, starting from a specified node or the root if no node is specified. generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree node), or `null`.

  #### Returns null | N

  The function `getLeftMost` returns the leftmost node in a binary tree. If the `beginRoot` parameter is provided, it starts the traversal from that node. If `beginRoot` is not provided or is `null`, it starts the traversal from the root of the binary tree. The function returns the leftmost node found during the traversal. If no leftmost node is found (

  Implementation of ITreeMultiset.getLeftMost

  Inherited from AVLTree.getLeftMost

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:638
- getLeftMost(node?): N

- The function `getLeftMost` returns the leftmost node in a binary tree, starting from a specified node or the root if no node is specified.

  #### Parameters

  - ##### `Optional` node: N

    The `beginRoot` parameter is optional and can be of type `N` (a generic type representing a node in a binary tree), `BinaryTreeNodeId` (a type representing the ID of a binary tree node).

  #### Returns N

  The function `getLeftMost` returns the leftmost node in a binary tree. If the `beginRoot` parameter is provided, it starts the traversal from that node. If `beginRoot` is not provided or is `null`, it starts the traversal from the root of the binary tree. The function returns the leftmost node found during the traversal. If no leftmost node is found (

  Implementation of ITreeMultiset.getLeftMost

  Inherited from AVLTree.getLeftMost

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:651

### getMinHeight

- getMinHeight(beginRoot?): number

- The `getMinHeight` function calculates the minimum height of a binary tree using either a recursive or iterative approach.

  #### Parameters

  - ##### `Optional` beginRoot: null | N

    The `beginRoot` parameter is an optional parameter of type `N` or `null`. It represents the starting node from which to calculate the minimum height of a binary tree. If no value is provided for `beginRoot`, the `this.root` property is used as the default value.

  #### Returns number

  The function `getMinHeight` returns the minimum height of the binary tree.

  Implementation of ITreeMultiset.getMinHeight

  Inherited from AVLTree.getMinHeight

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:479

### getNodes

- getNodes(nodeProperty, propertyName?, onlyOne?): N[]

- The function `getNodes` returns an array of nodes in a binary tree that match a given property value.

  #### Parameters

  - ##### nodeProperty: number | N

    The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or an `N` type. It represents the property of the binary tree node that you want to compare with.

  - ##### `Optional` propertyName: BinaryTreeNodePropertyName = 'id'

    The `propertyName` parameter is an optional parameter that specifies the property name to use for comparison. If not provided, it defaults to `'id'`.

  - ##### `Optional` onlyOne: boolean

    The `onlyOne` parameter is an optional boolean parameter that determines whether to return only one node that matches the given `nodeProperty` or all nodes that match the `nodeProperty`. If `onlyOne` is set to `true`, the function will return an array with only one node (if

  #### Returns N[]

  an array of nodes (type N).

  Implementation of ITreeMultiset.getNodes

  Inherited from AVLTree.getNodes

  - Defined in src/data-structures/binary-tree/bst.ts:240

### getNodesByCount

- getNodesByCount(nodeProperty, onlyOne?): N[]

- The function `getNodesByCount` returns an array of nodes that have a specific count property, either recursively or using a queue.

  #### Parameters

  - ##### nodeProperty: number | N

    The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a `N`. It represents the property of the nodes that you want to search for.

  - ##### `Optional` onlyOne: boolean

    The `onlyOne` parameter is an optional boolean parameter that determines whether to return only one node that matches the `nodeProperty` or all nodes that match the `nodeProperty`. If `onlyOne` is set to `true`, the function will return only one node. If `onlyOne`

  #### Returns N[]

  an array of nodes that match the given nodeProperty.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:486

### getPathToRoot

- getPathToRoot(node, isReverse?): N[]

- The function `getPathToRoot` returns an array of nodes representing the path from a given node to the root node, with an option to reverse the order of the nodes.

  #### Parameters

  - ##### node: N

    The `node` parameter represents a node in a tree structure. It is of type `N`, which could be any type that represents a node in your specific implementation.

  - ##### `Optional` isReverse: boolean = true

    The `isReverse` parameter is a boolean flag that determines whether the resulting path should be reversed or not. If `isReverse` is set to `true`, the path will be reversed before returning it. If `isReverse` is set to `false` or not provided, the path will

  #### Returns N[]

  The function `getPathToRoot` returns an array of nodes (`N[]`).

  Implementation of ITreeMultiset.getPathToRoot

  Inherited from AVLTree.getPathToRoot

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:615

### getPredecessor

- getPredecessor(node): N

- The function returns the predecessor of a given node in a binary tree.

  #### Parameters

  - ##### node: N

    The parameter `node` is a BinaryTreeNode object, representing a node in a binary tree.

  #### Returns N

  the predecessor of the given node in a binary tree.

  Implementation of ITreeMultiset.getPredecessor

  Inherited from AVLTree.getPredecessor

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1284

### getRightMost

- getRightMost(): null | N

- The `getRightMost` function returns the rightmost node in a binary tree, either recursively or iteratively using tail recursion optimization.

  #### Returns null | N

  The `getRightMost` function returns the rightmost node in a binary tree. It returns the rightmost node starting from the root of the binary tree.

  Implementation of ITreeMultiset.getRightMost

  Inherited from AVLTree.getRightMost

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:694
- getRightMost(node?): N

- The `getRightMost` function returns the rightmost node in a binary tree, either recursively or iteratively using tail recursion optimization.

  #### Parameters

  - ##### `Optional` node: N

    The `node` parameter is an optional parameter of type `N` or `null`. It represents the starting node from which we want to find the rightmost node. If no node is provided, the function will default to using the root node of the data structure.

  #### Returns N

  The `getRightMost` function returns the rightmost node in a binary tree. It returns the rightmost node starting from that node.

  Implementation of ITreeMultiset.getRightMost

  Inherited from AVLTree.getRightMost

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:705

### getSubTreeCount

- getSubTreeCount(subTreeRoot): [number, number]

- The function `getSubTreeCount` calculates the number of nodes and the sum of their counts in a subtree, using either recursive or iterative traversal.

  #### Parameters

  - ##### subTreeRoot: undefined | null | N

    The `subTreeRoot` parameter represents the root node of a subtree in a binary tree.

  #### Returns [number, number]

  The function `getSubTreeCount` returns an array `[number, number]`.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:368

### getSubTreeSize

- getSubTreeSize(subTreeRoot): number

- The function calculates the size of a subtree by traversing it either recursively or iteratively.

  #### Parameters

  - ##### subTreeRoot: undefined | null | N

    The `subTreeRoot` parameter represents the root node of a subtree in a binary tree.

  #### Returns number

  the size of the subtree rooted at `subTreeRoot`.

  Implementation of ITreeMultiset.getSubTreeSize

  Inherited from AVLTree.getSubTreeSize

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:789

### has

- has(nodeProperty, propertyName?): boolean

- The function checks if a binary tree node has a specific property.

  #### Parameters

  - ##### nodeProperty: number | N

    The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or `N`. It represents the property of the binary tree node that you want to check.

  - ##### `Optional` propertyName: BinaryTreeNodePropertyName

    The `propertyName` parameter is an optional parameter that specifies the name of the property to be checked in the nodes. If not provided, it defaults to 'id'.

  #### Returns boolean

  a boolean value.

  Implementation of ITreeMultiset.has

  Inherited from AVLTree.has

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:582

### isAVLBalanced

- isAVLBalanced(): boolean

- The function `isAVLBalanced` checks if a binary tree is balanced according to the AVL tree property.

  #### Returns boolean

  a boolean value.

  Implementation of ITreeMultiset.isAVLBalanced

  Inherited from AVLTree.isAVLBalanced

  - Defined in src/data-structures/binary-tree/bst.ts:475

### isBST

- isBST(): boolean

- The function isBST checks if the binary tree is valid binary search tree.

  #### Returns boolean

  The `isBST()` function is returning a boolean value.

  Implementation of ITreeMultiset.isBST

  Inherited from AVLTree.isBST

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:779

### isEmpty

- isEmpty(): boolean

- The function checks if the size of an object is equal to zero and returns a boolean value.

  #### Returns boolean

  A boolean value indicating whether the size of the object is 0 or not.

  Implementation of ITreeMultiset.isEmpty

  Inherited from AVLTree.isEmpty

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:237

### isPerfectlyBalanced

- isPerfectlyBalanced(beginRoot?): boolean

- The function checks if a binary tree is perfectly balanced by comparing the minimum height and the height of the tree.

  #### Parameters

  - ##### `Optional` beginRoot: null | N

    The parameter `beginRoot` is of type `N` or `null`. It represents the root node of a tree or null if the tree is empty.

  #### Returns boolean

  The method is returning a boolean value.

  Implementation of ITreeMultiset.isPerfectlyBalanced

  Inherited from AVLTree.isPerfectlyBalanced

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:529

### isSubtreeBST

- isSubtreeBST(node): boolean

- The function checks if a binary search tree is valid by traversing it either recursively or iteratively.

  #### Parameters

  - ##### node: null | N

    The `node` parameter represents the root node of a binary search tree (BST).

  #### Returns boolean

  a boolean value.

  Implementation of ITreeMultiset.isSubtreeBST

  Inherited from AVLTree.isSubtreeBST

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:745

### lastKey

- lastKey(): number

- The function returns the id of the rightmost node if the comparison between two values is less than, the id of the leftmost node if the comparison is greater than, and the id of the rightmost node otherwise.

  #### Returns number

  The method `lastKey()` returns the id of the rightmost node in the binary tree if the comparison between the values at index 0 and 1 is less than, otherwise it returns the id of the leftmost node. If the comparison is equal, it returns the id of the rightmost node. If there are no nodes in the tree, it returns 0.

  Implementation of ITreeMultiset.lastKey

  Inherited from AVLTree.lastKey

  - Defined in src/data-structures/binary-tree/bst.ts:223

### lesserSum

- lesserSum(beginNode, propertyName?): number

- The `lesserSum` function calculates the sum of property values in a binary tree for nodes that have a property value less than a given node.

  #### Parameters

  - ##### beginNode: null | number | N

    The `beginNode` parameter can be one of the following:

  - ##### `Optional` propertyName: BinaryTreeNodePropertyName

    The `propertyName` parameter is an optional parameter that specifies the property name to use for calculating the sum. If not provided, it defaults to `'id'`.

  #### Returns number

  The function `lesserSum` returns a number, which represents the sum of the values of the nodes in the binary tree that have a lesser value than the specified `beginNode` based on the `propertyName`.

  Implementation of ITreeMultiset.lesserSum

  Inherited from AVLTree.lesserSum

  - Defined in src/data-structures/binary-tree/bst.ts:293

### lesserSumCount

- lesserSumCount(beginNode): number

- The `lesserSumCount` function calculates the sum of the counts of all nodes in a binary tree that have a lesser value than a given node.

  #### Parameters

  - ##### beginNode: null | number | N

    The `beginNode` parameter can be one of the following:

  #### Returns number

  the sum of the counts of nodes in the binary tree that have a lesser value than the given beginNode.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:591

### levelIterative

- levelIterative(node): number[]

- Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on their 'id' property.

  #### Parameters

  - ##### node: null | N

    The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.

  #### Returns number[]

  An array of binary tree node IDs.

  Implementation of ITreeMultiset.levelIterative

  Inherited from AVLTree.levelIterative

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1130
- levelIterative(node, nodeOrPropertyName?): number[]

- Performs a level-order traversal on a binary tree starting from the specified node and accumulates properties of each node based on the specified property name.

  #### Parameters

  - ##### node: null | N

    The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.

  - ##### `Optional` nodeOrPropertyName: "id"

    The name of the property to accumulate.

  #### Returns number[]

  An array of values corresponding to the specified property.

  Implementation of ITreeMultiset.levelIterative

  Inherited from AVLTree.levelIterative

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1138
- levelIterative(node, nodeOrPropertyName?): N["val"][]

- Performs a level-order traversal on a binary tree starting from the specified node and accumulates the 'val' property of each node.

  #### Parameters

  - ##### node: null | N

    The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.

  - ##### `Optional` nodeOrPropertyName: "val"

    The name of the property to accumulate.

  #### Returns N["val"][]

  An array of 'val' properties from each node.

  Implementation of ITreeMultiset.levelIterative

  Inherited from AVLTree.levelIterative

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1146
- levelIterative(node, nodeOrPropertyName?): N[]

- Performs a level-order traversal on a binary tree starting from the specified node and accumulates nodes themselves.

  #### Parameters

  - ##### node: null | N

    The starting node for the level order traversal. If null, the root node of the tree is used as the starting node.

  - ##### `Optional` nodeOrPropertyName: "node"

    The name of the property to accumulate.

  #### Returns N[]

  An array of binary tree nodes.

  Implementation of ITreeMultiset.levelIterative

  Inherited from AVLTree.levelIterative

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1154

### listLevels

- listLevels(node): number[][]

- Collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | N

    The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.

  #### Returns number[][]

  A 2D array of AbstractBinaryTreeNodeProperty<N> objects.

  Implementation of ITreeMultiset.listLevels

  Inherited from AVLTree.listLevels

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1197
- listLevels(node, nodeOrPropertyName?): number[][]

- Collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | N

    The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.

  - ##### `Optional` nodeOrPropertyName: "id"

  #### Returns number[][]

  Implementation of ITreeMultiset.listLevels

  Inherited from AVLTree.listLevels

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1205
- listLevels(node, nodeOrPropertyName?): N["val"][][]

- Collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | N

    The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.

  - ##### `Optional` nodeOrPropertyName: "val"

    The property of the BinaryTreeNode object to collect at each level.

  #### Returns N["val"][][]

  A 2D array of 'val' properties from each node.

  Implementation of ITreeMultiset.listLevels

  Inherited from AVLTree.listLevels

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1213
- listLevels(node, nodeOrPropertyName?): N[][]

- Collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | N

    The root node of the binary tree or null. If null, the function will use the root node of the current binary tree instance.

  - ##### `Optional` nodeOrPropertyName: "node"

    The property of the BinaryTreeNode object to collect at each level.

  #### Returns N[][]

  A 2D array of binary tree nodes.

  Implementation of ITreeMultiset.listLevels

  Inherited from AVLTree.listLevels

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1221

### listLevelsCount

- listLevelsCount(node): number[][]

- The function "listLevelsCount" takes a node and returns an array of arrays, where each inner array contains the count property of each node at that level.

  #### Parameters

  - ##### node: null | N

    The parameter `node` is of type `N | null`. This means that it can either be an instance of the class `N` or `null`.

  #### Returns number[][]

  a 2D array of numbers. Each inner array represents a level in the binary tree, and each number in the inner array represents the count property of a node in that level.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:540

### morris

- morris(): number[]

- Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm.

  #### Returns number[]

  An array of binary tree node IDs.

  Implementation of ITreeMultiset.morris

  Inherited from AVLTree.morris

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1307
- morris(pattern?, nodeOrPropertyName?): number[]

- Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates properties of each node based on the specified property name.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "id"

    The name of the property to accumulate.

  #### Returns number[]

  An array of values corresponding to the specified property.

  Implementation of ITreeMultiset.morris

  Inherited from AVLTree.morris

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1315
- morris(pattern?, nodeOrPropertyName?): N[]

- Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates the 'val' property of each node.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "val"

    The property of the BinaryTreeNode object to collect at each level.

  #### Returns N[]

  An array of 'val' properties from each node.

  Implementation of ITreeMultiset.morris

  Inherited from AVLTree.morris

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1323
- morris(pattern?, nodeOrPropertyName?): N[]

- Performs an in-order, pre-order, or post-order traversal on a binary tree using the Morris traversal algorithm and accumulates nodes themselves.

  #### Parameters

  - ##### `Optional` pattern: DFSOrderPattern

    The traversal pattern: 'in' (in-order), 'pre' (pre-order), or 'post' (post-order).

  - ##### `Optional` nodeOrPropertyName: "node"

    The property of the BinaryTreeNode object to collect at each level.

  #### Returns N[]

  An array of binary tree nodes.

  Implementation of ITreeMultiset.morris

  Inherited from AVLTree.morris

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:1331

### morrisCount

- morrisCount(pattern?): number[]

- The `morrisCount` function returns an array of counts for each node in a binary tree, based on a specified traversal pattern.

  #### Parameters

  - ##### `Optional` pattern: "in" | "pre" | "post"

    The `pattern` parameter is an optional parameter that specifies the traversal pattern for the Morris traversal algorithm. It can have one of three values: 'in', 'pre', or 'post'.

  #### Returns number[]

  The function `morrisCount` returns an array of numbers.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:552

### perfectlyBalance

- perfectlyBalance(): boolean

- The `perfectlyBalance` function takes a binary tree, performs a depth-first search to sort the nodes, and then constructs a balanced binary search tree using either a recursive or iterative approach.

  #### Returns boolean

  The function `perfectlyBalance()` returns a boolean value.

  Implementation of ITreeMultiset.perfectlyBalance

  Overrides AVLTree.perfectlyBalance

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:258

### remove

- remove(nodeOrId, ignoreCount?): BinaryTreeDeletedResult <N>[]

- The `remove` function removes a node from a binary search tree and returns the deleted node along with the parent node that needs to be balanced.

  #### Parameters

  - ##### nodeOrId: number | N

    The `nodeOrId` parameter can be one of the following:

  - ##### `Optional` ignoreCount: boolean

    The `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 taken into account when removing it. If `ignoreCount` is set to `false @returns The function` remove`returns an array of`BinaryTreeDeletedResult<N>` objects.

  #### Returns BinaryTreeDeletedResult <N>[]

  Implementation of ITreeMultiset.remove

  Overrides AVLTree.remove

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:305

### subTreeAdd

- subTreeAdd(subTreeRoot, delta, propertyName?): boolean

- The function `subTreeAdd` adds a delta value to a specified property of each node in a subtree.

  #### Parameters

  - ##### subTreeRoot: null | number | N

    The `subTreeRoot` parameter represents the root node of a binary tree or the ID of a node in the binary tree. It can also be `null` if there is no subtree to add to.

  - ##### delta: number

    The `delta` parameter is a number that represents the amount by which the property value of each node in the subtree should be incremented.

  - ##### `Optional` propertyName: BinaryTreeNodePropertyName

    The `propertyName` parameter is an optional parameter that specifies the property of the binary tree node that should be modified. If not provided, it defaults to 'id'.

  #### Returns boolean

  a boolean value.

  Implementation of ITreeMultiset.subTreeAdd

  Inherited from AVLTree.subTreeAdd

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:882

### subTreeAddCount

- subTreeAddCount(subTreeRoot, delta): boolean

- The function `subTreeAddCount` recursively or iteratively traverses a binary tree and adds a given delta value to the `count` property of each node.

  #### Parameters

  - ##### subTreeRoot: null | number | N

    The `subTreeRoot` parameter represents the root node of a subtree in a binary tree. It can be either a `BinaryTreeNodeId` (a unique identifier for a node in the binary tree), a `BinaryTreeNode` object, or `null` if the subtree is empty.

  - ##### delta: number

    The delta parameter is a number that represents the amount by which the count of each node in the subtree should be increased or decreased.

  #### Returns boolean

  a boolean value.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:444

### subTreeSum

- subTreeSum(subTreeRoot, propertyName?): number

- The function `subTreeSum` calculates the sum of a specified property in a binary tree or subtree.

  #### Parameters

  - ##### subTreeRoot: null | number | N

    The `subTreeRoot` parameter represents the root node of a binary tree or the ID of a binary tree node. It can also be `null` if there is no subtree.

  - ##### `Optional` propertyName: BinaryTreeNodePropertyName

    propertyName is an optional parameter that specifies the property of the binary tree node to use for calculating the sum. It can be either 'id' or 'val'. If propertyName is not provided, it defaults to 'id'.

  #### Returns number

  a number, which is the sum of the values of the specified property in the subtree rooted at `subTreeRoot`.

  Implementation of ITreeMultiset.subTreeSum

  Inherited from AVLTree.subTreeSum

  - Defined in src/data-structures/binary-tree/abstract-binary-tree.ts:826

### subTreeSumCount

- subTreeSumCount(subTreeRoot): number

- The function `subTreeSumCount` calculates the sum of the `count` property of each node in a subtree, either recursively or iteratively.

  #### Parameters

  - ##### subTreeRoot: null | number | N

    The `subTreeRoot` parameter represents the root node of a subtree in a binary tree. It can be either a `BinaryTreeNodeId` (a unique identifier for a node in the binary tree) or `null` if the subtree is empty.

  #### Returns number

  the sum of the count values of all nodes in the subtree rooted at `subTreeRoot`.

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:405

### swapLocation

- swapLocation(srcNode, destNode): N

- The function swaps the location of two nodes in a tree data structure.

  #### Parameters

  - ##### srcNode: N

    The source node that we want to swap with the destination node.

  - ##### destNode: N

    The `destNode` parameter represents the destination node where the values from `srcNode` will be swapped with.

  #### Returns N

  the `destNode` after swapping its values with the `srcNode`.

  Implementation of ITreeMultiset.swapLocation

  Overrides AVLTree.swapLocation

  - Defined in src/data-structures/binary-tree/tree-multiset.ts:86

Generated using TypeDoc