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

# Class AVLTree<T>

#### Type Parameters

- #### T

#### Hierarchy

- BST <T>
  - AVLTree

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

#####
Index

### Constructors

constructor

### Properties

_comparator
_count
_loopType
_root
_size
_visitedCount
_visitedId
_visitedLeftSum
_visitedNode
_visitedVal

### Accessors

count
root
size

### Methods

BFS
DFS
DFSIterative
_accumulatedByPropertyName
_compare
_getResultByPropertyName
_pushByPropertyNameStopOrNot
_resetResults
allGreaterNodesAdd
balance
balanceFactor
balanceLL
balanceLR
balancePath
balanceRL
balanceRR
clear
createNode
fill
get
getDepth
getHeight
getLeftMost
getMinHeight
getNodes
getPathToRoot
getPredecessor
getRightMost
getSubTreeSizeAndCount
has
insertMany
isAVLBalanced
isBST
isBalanced
isEmpty
lastKey
lesserSum
levelIterative
listLevels
morris
put
putTo
remove
subTreeAdd
subTreeSum
updateHeight

## Constructors

### constructor

- new AVLTree<T>(options?): AVLTree <T>

- #### Type Parameters

  - #### T

  #### Parameters

  - ##### `Optional` options: {
    comparator?: BSTComparator;
    loopType?: LoopType ;
    }

    - ##### `Optional` comparator?: BSTComparator

    - ##### `Optional` loopType?: LoopType

  #### Returns AVLTree <T>

  Inherited from BST.constructor

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

## Properties

### `Protected` _comparator

_comparator: BSTComparator = ...

Inherited from BST._comparator

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

### `Protected` _count

_count: number = 0

Inherited from BST._count

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

### `Protected` _loopType

_loopType: LoopType = LoopType.iterative

Inherited from BST._loopType

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

### `Protected` _root

_root: null | BinaryTreeNode <T> = null

Inherited from BST._root

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

### `Protected` _size

_size: number = 0

Inherited from BST._size

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

### `Protected` _visitedCount

_visitedCount: number[] = []

Inherited from BST._visitedCount

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

### `Protected` _visitedId

_visitedId: number[] = []

Inherited from BST._visitedId

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

### `Protected` _visitedLeftSum

_visitedLeftSum: number[] = []

Inherited from BST._visitedLeftSum

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

### `Protected` _visitedNode

_visitedNode: BinaryTreeNode <T>[] = []

Inherited from BST._visitedNode

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

### `Protected` _visitedVal

_visitedVal: T[] = []

Inherited from BST._visitedVal

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

## Accessors

### count

- get count(): number

- #### Returns number

  Inherited from BST.count

  - Defined in src/data-structures/binary-tree/binary-tree.ts:199
- set count(v): void

- #### Parameters

  - ##### v: number

  #### Returns void

  Inherited from BST.count

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

### root

- get root(): null | BinaryTreeNode <T>

- #### Returns null | BinaryTreeNode <T>

  Inherited from BST.root

  - Defined in src/data-structures/binary-tree/binary-tree.ts:175
- set root(v): void

- #### Parameters

  - ##### v: null | BinaryTreeNode <T>

  #### Returns void

  Inherited from BST.root

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

### size

- get size(): number

- #### Returns number

  Inherited from BST.size

  - Defined in src/data-structures/binary-tree/binary-tree.ts:189
- set size(v): void

- #### Parameters

  - ##### v: number

  #### Returns void

  Inherited from BST.size

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

## Methods

### BFS

- BFS(): number[]

- The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.

  #### Returns number[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.BFS

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

- The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.

  #### Parameters

  - ##### nodeOrPropertyName: "id"

    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

  #### Returns number[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.BFS

  - Defined in src/data-structures/binary-tree/binary-tree.ts:904
- BFS(nodeOrPropertyName): T[]

- The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.

  #### Parameters

  - ##### nodeOrPropertyName: "val"

    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

  #### Returns T[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.BFS

  - Defined in src/data-structures/binary-tree/binary-tree.ts:906
- BFS(nodeOrPropertyName): BinaryTreeNode <T>[]

- The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.

  #### Parameters

  - ##### nodeOrPropertyName: "node"

    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

  #### Returns BinaryTreeNode <T>[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.BFS

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

- The BFS function performs a breadth-first search on a binary tree and returns the results based on a specified node or property name.

  #### Parameters

  - ##### nodeOrPropertyName: "count"

    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

  #### Returns number[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.BFS

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

### DFS

- DFS(): number[]

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

  #### Returns number[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.DFS

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

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

  #### Parameters

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

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

  #### Returns number[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.DFS

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

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

  #### Parameters

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

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

  #### Returns T[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.DFS

  - Defined in src/data-structures/binary-tree/binary-tree.ts:942
- DFS(pattern?, nodeOrPropertyName?): BinaryTreeNode <T>[]

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

  #### Parameters

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

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

  #### Returns BinaryTreeNode <T>[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.DFS

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

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

  #### Parameters

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

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

  #### Returns number[]

  an object of type `ResultsByProperty<T>`.

  Inherited from BST.DFS

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

### DFSIterative

- DFSIterative(): number[]

- Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack

  #### Returns number[]

  Inherited from BST.DFSIterative

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

- Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack

  #### Parameters

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

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

  #### Returns number[]

  Inherited from BST.DFSIterative

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

- Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack

  #### Parameters

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

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

  #### Returns T[]

  Inherited from BST.DFSIterative

  - Defined in src/data-structures/binary-tree/binary-tree.ts:992
- DFSIterative(pattern?, nodeOrPropertyName?): BinaryTreeNode <T>[]

- Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack

  #### Parameters

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

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

  #### Returns BinaryTreeNode <T>[]

  Inherited from BST.DFSIterative

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

- Time complexity is O(n) Space complexity of Iterative DFS equals to recursive DFS which is O(n) because of the stack

  #### Parameters

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

  - ##### `Optional` nodeOrPropertyName: "count"

  #### Returns number[]

  Inherited from BST.DFSIterative

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

### `Protected` _accumulatedByPropertyName

- _accumulatedByPropertyName(node, nodeOrPropertyName?): void

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

  #### Parameters

  - ##### node: BinaryTreeNode <T>

    The `node` parameter is of type `BinaryTreeNode<T>`, which represents a node in a binary tree.

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

    The 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

  #### Returns void

  Inherited from BST._accumulatedByPropertyName

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

### `Protected` _compare

- _compare(a, b): CP

- #### Parameters

  - ##### a: number

  - ##### b: number

  #### Returns CP

  Inherited from BST._compare

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

### `Protected` _getResultByPropertyName

- _getResultByPropertyName(nodeOrPropertyName?): ResultsByProperty<T>

- The function `_getResultByPropertyName` returns different results based on the provided property name or defaulting to 'id'.

  #### Parameters

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

    The parameter `nodeOrPropertyName` is an optional parameter that can accept a value of type `NodeOrPropertyName`.

  #### Returns ResultsByProperty<T>

  The method returns an object of type `ResultsByProperty<T>`.

  Inherited from BST._getResultByPropertyName

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

### `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: BinaryTreeNode <T>

    The current binary tree node that is being checked.

  - ##### result: (undefined | null | BinaryTreeNode <T>)[]

    An array that stores the matching nodes found during the traversal.

  - ##### nodeProperty: number | T

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

    The `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: 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 or not a node was pushed into the result array.

  Inherited from BST._pushByPropertyNameStopOrNot

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

### `Protected` _resetResults

- _resetResults(): void

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

  #### Returns void

  Inherited from BST._resetResults

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

### allGreaterNodesAdd

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

- #### Parameters

  - ##### node: BSTNode <T>

  - ##### delta: number

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

  #### Returns boolean

  Inherited from BST.allGreaterNodesAdd

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

### balance

- balance(): boolean

- #### Returns boolean

  Inherited from BST.balance

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

### 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: AVLTreeNode <T>

    The parameter "node" is of type AVLTreeNode<T>, which represents a node in an AVL tree.

  #### Returns number

  The balance factor of the given AVL tree node.

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

### balanceLL

- balanceLL(A): void

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

  #### Parameters

  - ##### A: AVLTreeNode <T>

    The parameter A is an AVLTreeNode object.

  #### Returns void

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

### balanceLR

- balanceLR(A): void

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

  #### Parameters

  - ##### A: AVLTreeNode <T>

    A is an AVLTreeNode object.

  #### Returns void

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

### 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: AVLTreeNode <T>

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

  #### Returns void

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

### balanceRL

- balanceRL(A): void

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

  #### Parameters

  - ##### A: AVLTreeNode <T>

    A is an AVLTreeNode object.

  #### Returns void

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

### balanceRR

- balanceRR(A): void

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

  #### Parameters

  - ##### A: AVLTreeNode <T>

    The parameter A is an AVLTreeNode object.

  #### Returns void

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

### clear

- clear(): void

- The clear function resets the state of an object by setting its properties to their initial values.

  #### Returns void

  Inherited from BST.clear

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

### createNode

- createNode(id, val, count?): AVLTreeNode <T>

- The function creates a new binary tree node with the given id, value, and count, or returns null if the value is null.

  #### Parameters

  - ##### id: number

    The `id` parameter is the identifier for the binary tree node. It is of type `BinaryTreeNodeId`, which could be a string or a number, depending on how you want to identify your nodes.

  - ##### val: T

    The `val` parameter represents the value to be stored in the binary tree node. It can be of any type `T` or `null`.

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

    The count parameter is an optional parameter that represents the number of occurrences of the value in the binary tree node. It is of type number.

  #### Returns AVLTreeNode <T>

  The function `createNode` returns a `BinaryTreeNode<T>` object if the `val` parameter is not null. Otherwise, it returns null.

  Overrides BST.createNode

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

### fill

- fill(data): boolean

- The `fill` function clears the current data and inserts new data, returning a boolean indicating if the insertion was successful.

  #### Parameters

  - ##### data: BinaryTreeNode <T>[] | T[]

    The `data` parameter can be either an array of elements of type `T` or an array of `BinaryTreeNode<T>` objects.

  #### Returns boolean

  The method is returning a boolean value.

  Inherited from BST.fill

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

### get

- get(nodeProperty, propertyName?): null | BSTNode <T>

- The function returns the first binary tree node that matches the given property name and value, or null if no match is found.

  #### Parameters

  - ##### nodeProperty: number | T

    The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a generic type `T`. 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 of the binary tree node to search for. If not provided, it defaults to `'id'`.

  #### Returns null | BSTNode <T>

  a BinaryTreeNode object or null.

  Inherited from BST.get

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

### getDepth

- getDepth(node): number

- The function calculates the depth of a binary tree node by traversing its parent nodes.

  #### Parameters

  - ##### node: BinaryTreeNode <T>

    BinaryTreeNode<T> - 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.

  #### Returns number

  The depth of the given binary tree node.

  Inherited from BST.getDepth

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

### getHeight

- getHeight(beginRoot?): number

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

  #### Parameters

  - ##### `Optional` beginRoot: null | BinaryTreeNode <T>

    The `beginRoot` parameter is an optional parameter of type `BinaryTreeNode<T> | 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

  #### Returns number

  the height of the binary tree.

  Inherited from BST.getHeight

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

### getLeftMost

- getLeftMost(): null | BinaryTreeNode <T>

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

  #### Returns null | BinaryTreeNode <T>

  The `getLeftMost` function returns the leftmost node in a binary tree.

  Inherited from BST.getLeftMost

  - Defined in src/data-structures/binary-tree/binary-tree.ts:651
- getLeftMost(node): BinaryTreeNode <T>

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

  #### Parameters

  - ##### node: BinaryTreeNode <T>

    The `node` parameter is an optional parameter of type `BinaryTreeNode<T> | 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.

  #### Returns BinaryTreeNode <T>

  The `getLeftMost` function returns the leftmost node in a binary tree.

  Inherited from BST.getLeftMost

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

### 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 | BinaryTreeNode <T>

    The `beginRoot` parameter is an optional parameter of type `BinaryTreeNode<T> | 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.

  #### Returns number

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

  Inherited from BST.getMinHeight

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

### getNodes

- getNodes(nodeProperty, propertyName?, onlyOne?): BSTNode <T>[]

- The function `getNodes` returns an array of binary tree nodes that match a given property value, with options for searching recursively or iteratively.

  #### Parameters

  - ##### nodeProperty: number | T

    The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a generic type `T`. 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 when searching for nodes. 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 `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 function`getNodes`returns an array of`BinaryTreeNode<T> | null | undefined` objects.

  #### Returns BSTNode <T>[]

  Inherited from BST.getNodes

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

### getPathToRoot

- getPathToRoot(node): BinaryTreeNode <T>[]

- The function getPathToRoot returns an array of BinaryTreeNode objects representing the path from a given node to the root of a binary tree.

  #### Parameters

  - ##### node: BinaryTreeNode <T>

    The `node` parameter is a BinaryTreeNode object.

  #### Returns BinaryTreeNode <T>[]

  The function `getPathToRoot` returns an array of `BinaryTreeNode<T>` objects, representing the path from the given `node` to the root of the binary tree.

  Inherited from BST.getPathToRoot

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

### getPredecessor

- getPredecessor(node): BinaryTreeNode <T>

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

  #### Parameters

  - ##### node: BinaryTreeNode <T>

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

  #### Returns BinaryTreeNode <T>

  the predecessor of the given node in a binary tree.

  Inherited from BST.getPredecessor

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

### getRightMost

- getRightMost(): null | BinaryTreeNode <T>

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

  #### Returns null | BinaryTreeNode <T>

  The `getRightMost` function returns the rightmost node in a binary tree.

  Inherited from BST.getRightMost

  - Defined in src/data-structures/binary-tree/binary-tree.ts:686
- getRightMost(node): BinaryTreeNode <T>

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

  #### Parameters

  - ##### node: BinaryTreeNode <T>

    The `node` parameter is an optional parameter of type `BinaryTreeNode<T> | 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.

  #### Returns BinaryTreeNode <T>

  The `getRightMost` function returns the rightmost node in a binary tree.

  Inherited from BST.getRightMost

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

### getSubTreeSizeAndCount

- getSubTreeSizeAndCount(subTreeRoot): [number, number]

- The function calculates the size and count of a subtree in a binary tree using either recursive or iterative traversal.

  #### Parameters

  - ##### subTreeRoot: undefined | null | BinaryTreeNode <T>

    The `subTreeRoot` parameter is the root node of a binary tree.

  #### Returns [number, number]

  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.

  Inherited from BST.getSubTreeSizeAndCount

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

### has

- has(nodeProperty, propertyName?): boolean

- The function checks if a binary tree node has a specific property or if any node in the tree has a specific property.

  #### Parameters

  - ##### nodeProperty: number | T

    The `nodeProperty` parameter can be either a `BinaryTreeNodeId` or a generic type `T`. It represents the property of a 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 check for in the nodes.

  #### Returns boolean

  a boolean value.

  Inherited from BST.has

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

### insertMany

- insertMany(data): (undefined | null | BinaryTreeNode <T>)[]

- The `insertMany` function inserts multiple items into a binary tree and returns an array of the inserted nodes or null/undefined values.

  #### Parameters

  - ##### data: BinaryTreeNode <T>[] | T[]

    The `data` parameter can be either an array of elements of type `T` or an array of `BinaryTreeNode<T>` objects.

  #### Returns (undefined | null | BinaryTreeNode <T>)[]

  The function `insertMany` returns an array of `BinaryTreeNode<T>`, `null`, or `undefined` values.

  Inherited from BST.insertMany

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

### isAVLBalanced

- isAVLBalanced(): boolean

- #### Returns boolean

  Inherited from BST.isAVLBalanced

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

### isBST

- isBST(node?): boolean

- The `isBST` function checks if a binary tree is a binary search tree.

  #### Parameters

  - ##### `Optional` node: null | BinaryTreeNode <T>

    The `node` parameter is an optional parameter of type `BinaryTreeNode<T> | null`. It represents the root node of the binary search tree (BST) that we want to check for validity. If no node is provided, the function will default to using the root node of the BST instance that

  #### Returns boolean

  The `isBST` function returns a boolean value. It returns `true` if the binary tree is a valid binary search tree, and `false` otherwise.

  Inherited from BST.isBST

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

### isBalanced

- isBalanced(beginRoot?): boolean

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

  #### Parameters

  - ##### `Optional` beginRoot: null | BinaryTreeNode <T>

    The `beginRoot` parameter is the root node of a binary tree. It is of type `BinaryTreeNode<T> | null`, which means it can either be a `BinaryTreeNode` object or `null`.

  #### Returns boolean

  The method is returning a boolean value.

  Inherited from BST.isBalanced

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

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

  Inherited from BST.isEmpty

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

### lastKey

- lastKey(): number

- #### Returns number

  Inherited from BST.lastKey

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

### lesserSum

- lesserSum(id, propertyName?): number

- #### Parameters

  - ##### id: number

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

  #### Returns number

  Inherited from BST.lesserSum

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

### levelIterative

- levelIterative(node): number[]

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

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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.

  #### Returns number[]

  The function `levelIterative` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.levelIterative

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

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

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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

  #### Returns number[]

  The function `levelIterative` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.levelIterative

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

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

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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

  #### Returns T[]

  The function `levelIterative` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.levelIterative

  - Defined in src/data-structures/binary-tree/binary-tree.ts:1051
- levelIterative(node, nodeOrPropertyName?): BinaryTreeNode <T>[]

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

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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

  #### Returns BinaryTreeNode <T>[]

  The function `levelIterative` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.levelIterative

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

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

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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

  #### Returns number[]

  The function `levelIterative` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.levelIterative

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

### listLevels

- listLevels(node): number[][]

- The `listLevels` function collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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.

  #### Returns number[][]

  The function `listLevels` returns a 2D array of `ResultByProperty<T>` objects.

  Inherited from BST.listLevels

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

- The `listLevels` function collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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:

  #### Returns number[][]

  The function `listLevels` returns a 2D array of `ResultByProperty<T>` objects.

  Inherited from BST.listLevels

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

- The `listLevels` function collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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:

  #### Returns T[][]

  The function `listLevels` returns a 2D array of `ResultByProperty<T>` objects.

  Inherited from BST.listLevels

  - Defined in src/data-structures/binary-tree/binary-tree.ts:1097
- listLevels(node, nodeOrPropertyName?): BinaryTreeNode <T>[][]

- The `listLevels` function collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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:

  #### Returns BinaryTreeNode <T>[][]

  The function `listLevels` returns a 2D array of `ResultByProperty<T>` objects.

  Inherited from BST.listLevels

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

- The `listLevels` function collects nodes from a binary tree by a specified property and organizes them into levels.

  #### Parameters

  - ##### node: null | BinaryTreeNode <T>

    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:

  #### Returns number[][]

  The function `listLevels` returns a 2D array of `ResultByProperty<T>` objects.

  Inherited from BST.listLevels

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

### morris

- morris(): number[]

- 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

  #### Returns number[]

  The function `morris` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.morris

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

- 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

  #### Parameters

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

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

  #### Returns number[]

  The function `morris` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.morris

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

- 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

  #### Parameters

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

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

  #### Returns T[]

  The function `morris` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.morris

  - Defined in src/data-structures/binary-tree/binary-tree.ts:1188
- morris(pattern?, nodeOrPropertyName?): BinaryTreeNode <T>[]

- 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

  #### Parameters

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

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

  #### Returns BinaryTreeNode <T>[]

  The function `morris` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.morris

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

- 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

  #### Parameters

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

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

  #### Returns number[]

  The function `morris` returns an object of type `ResultsByProperty<T>`.

  Inherited from BST.morris

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

### put

- put(id, val, count?): null | AVLTreeNode <T>

- The function overrides the put method of a Binary Search Tree to insert a node with a given id and value, and then balances the tree.

  #### Parameters

  - ##### id: number

    The `id` parameter is the identifier of the binary tree node that we want to put or update in the AVL tree.

  - ##### val: null | T

    The `val` parameter represents the value that you want to assign to the node with the given `id`. It can be of type `T` (the generic type) or `null`.

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

    The `count` parameter is an optional parameter of type `number`. It represents the number of times the value `val` should be inserted into the AVL tree. If the `count` parameter is not provided, it defaults to `1`, indicating that the value should be inserted once.

  #### Returns null | AVLTreeNode <T>

  The method is returning either an AVLTreeNode<T> object or null.

  Overrides BST.put

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

### putTo

- putTo(newNode, parent): undefined | null | BinaryTreeNode <T>

- The function inserts a new node into a binary tree as the left or right child of a given parent node.

  #### Parameters

  - ##### newNode: null | BinaryTreeNode <T>

    The `newNode` parameter is an instance of the `BinaryTreeNode` class or `null`. It represents the node that needs to be inserted into the binary tree.

  - ##### parent: BinaryTreeNode <T>

    The `parent` parameter is a BinaryTreeNode object representing the parent node to which the new node will be inserted as a child.

  #### Returns undefined | null | BinaryTreeNode <T>

  The method returns the newly inserted node, either as the left child or the right child of the parent node.

  Inherited from BST.putTo

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

### remove

- remove(id, isUpdateAllLeftSum?): AVLTreeDeleted<T>[]

- The function overrides the remove method of the Binary Search Tree class, performs the removal operation, and then balances the tree if necessary.

  #### Parameters

  - ##### id: number

    The `id` parameter represents the identifier of the binary tree node that needs to be removed from the AVL tree.

  - ##### `Optional` isUpdateAllLeftSum: boolean

    The `isUpdateAllLeftSum` parameter is an optional boolean parameter that determines whether the left sum of all nodes in the AVL tree should be updated after removing a node. If `isUpdateAllLeftSum` is set to `true`, the left sum of all nodes will be recalculated.

  #### Returns AVLTreeDeleted<T>[]

  The method is returning an array of `AVLTreeDeleted<T>` objects.

  Overrides BST.remove

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

### subTreeAdd

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

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

  #### Parameters

  - ##### subTreeRoot: BinaryTreeNode <T>

    The `subTreeRoot` parameter is the root node of the subtree where the values will be modified.

  - ##### 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 increased or decreased.

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

    The `propertyName` parameter is an optional parameter that specifies the property of the `BinaryTreeNode` that should be modified. It defaults to `'id'` if not provided.

  #### Returns boolean

  a boolean value, which is `true`.

  Inherited from BST.subTreeAdd

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

### subTreeSum

- subTreeSum(subTreeRoot, propertyName?): number

- The function `subTreeSum` calculates the sum of a specified property in a binary tree, either recursively or iteratively.

  #### Parameters

  - ##### subTreeRoot: BinaryTreeNode <T>

    The subTreeRoot parameter is the root node of the subtree for which you want to calculate the sum.

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

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

  #### Returns number

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

  Inherited from BST.subTreeSum

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

### 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: AVLTreeNode <T>

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

  #### Returns void

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

Generated using TypeDoc