Skip to main content

BSTNode

data-structure-typed


data-structure-typed / BSTNode

Class: BSTNode<K, V>

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

Represents a Node in a Binary Search Tree.

Type Parameters

K

K = any

The type of the key.

V

V = any

The type of the value.

Constructors

Constructor

new BSTNode<K, V>(key, value?): BSTNode<K, V>;

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

Creates an instance of BSTNode.

Parameters

key

K

The key of the node.

value?

V

The value associated with the key.

Returns

BSTNode<K, V>

Remarks

Time O(1), Space O(1)

Accessors

color

Get Signature

get color(): RBTNColor;

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

Gets the color of the node (used in Red-Black trees).

Remarks

Time O(1), Space O(1)

Returns

RBTNColor

The node's color.

Set Signature

set color(value): void;

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

Sets the color of the node.

Remarks

Time O(1), Space O(1)

Parameters
value

RBTNColor

The new color.

Returns

void


count

Get Signature

get count(): number;

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

Gets the count of nodes in the subtree rooted at this node (used in order-statistic trees).

Remarks

Time O(1), Space O(1)

Returns

number

The subtree node count.

Set Signature

set count(value): void;

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

Sets the count of nodes in the subtree.

Remarks

Time O(1), Space O(1)

Parameters
value

number

The new count.

Returns

void


familyPosition

Get Signature

get familyPosition(): FamilyPosition;

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

Gets the position of the node relative to its parent.

Remarks

Time O(1), Space O(1)

Returns

FamilyPosition

The family position (e.g., 'ROOT', 'LEFT', 'RIGHT').


height

Get Signature

get height(): number;

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

Gets the height of the node (used in self-balancing trees).

Remarks

Time O(1), Space O(1)

Returns

number

The height.

Set Signature

set height(value): void;

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

Sets the height of the node.

Remarks

Time O(1), Space O(1)

Parameters
value

number

The new height.

Returns

void


left

Get Signature

get left(): BSTNode<K, V> | null | undefined;

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

Gets the left child of the node.

Remarks

Time O(1), Space O(1)

Returns

BSTNode<K, V> | null | undefined

The left child.

Set Signature

set left(v): void;

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

Sets the left child of the node and updates its parent reference.

Remarks

Time O(1), Space O(1)

Parameters
v

BSTNode<K, V> | null | undefined

The node to set as the left child.

Returns

void


Get Signature

get right(): BSTNode<K, V> | null | undefined;

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

Gets the right child of the node.

Remarks

Time O(1), Space O(1)

Returns

BSTNode<K, V> | null | undefined

The right child.

Set Signature

set right(v): void;

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

Sets the right child of the node and updates its parent reference.

Remarks

Time O(1), Space O(1)

Parameters
v

BSTNode<K, V> | null | undefined

The node to set as the right child.

Returns

void