Class BSTNode<K, V>

Represents a Node in a Binary Search Tree.

Type Parameters

  • K = any

    The type of the key.

  • V = any

    The type of the value.

Hierarchy (view full)

Constructors

Accessors

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

    Returns number

    The subtree node count.

    Time O(1), Space O(1)

  • set count(value): void
  • Sets the count of nodes in the subtree.

    Parameters

    • value: number

      The new count.

    Returns void

    Time O(1), Space O(1)

  • get familyPosition(): FamilyPosition
  • Gets the position of the node relative to its parent.

    Returns FamilyPosition

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

    Time O(1), Space O(1)

  • get left(): undefined | null | BSTNode<K, V>
  • Gets the left child of the node.

    Returns undefined | null | BSTNode<K, V>

    The left child.

    Time O(1), Space O(1)

  • set left(v): void
  • Sets the left child of the node and updates its parent reference.

    Parameters

    • v: undefined | null | BSTNode<K, V>

      The node to set as the left child.

    Returns void

    Time O(1), Space O(1)

  • get right(): undefined | null | BSTNode<K, V>
  • Gets the right child of the node.

    Returns undefined | null | BSTNode<K, V>

    The right child.

    Time O(1), Space O(1)

  • set right(v): void
  • Sets the right child of the node and updates its parent reference.

    Parameters

    • v: undefined | null | BSTNode<K, V>

      The node to set as the right child.

    Returns void

    Time O(1), Space O(1)