Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • T

Hierarchy

Index

Constructors

Properties

$ROOT: null | Node<T>
compare: compare<T>

Accessors

  • get height(): number
  • get toArray(): T[]

Methods

  • adjustHeight(node: null | Node<T>): void
  • Parameters

    • node: null | Node<T>

    Returns void

  • delete(data: T): void
  • Parameters

    • data: T

    Returns void

  • deleteElement(target: Node<T>): void
  • Parameters

    • target: Node<T>

    Returns void

  • findNode(data: T, end?: boolean, root?: null | Node<T>): null | Node<T>
  • Find Node with data in BST

    It find the node with the given data and if node doesn't exists it return null

    Parameters

    • data: T

      target data to search

    • end: boolean = false

      Get first occurrence of node

    • root: null | Node<T> = ...

    Returns null | Node<T>

    Node in BST | Null if node not found

  • inorder(root: null | Node<T>, array?: T[]): T[]
  • Parameters

    • root: null | Node<T>
    • array: T[] = []

    Returns T[]

  • insert(data: T): Node<T>
  • Parameters

    • data: T

    Returns Node<T>

  • insertionPoint(data: T, root?: null | Node<T>): null | Node<T>
  • Find Insertion Point for new Node in BST

    It find the node with the given data and if node doesn't exists it return the position where the node can be inserted.

    Parameters

    • data: T

      target data to insert

    • root: null | Node<T> = ...

    Returns null | Node<T>

    Node in BST | Null if tree is empty

  • leftAncestor(node: Node<T>): null | Node<T>
  • Parameters

    • node: Node<T>

      The reference node

    Returns null | Node<T>

    The ancestor of a node with the next largest data | null if right ancestor doesn't exists

  • leftDescendant(node: Node<T>): Node<T>
  • Parameters

    • node: Node<T>

    Returns Node<T>

  • next(node: Node<T>): null | Node<T>
  • Parameters

    • node: Node<T>

      The reference node

    Returns null | Node<T>

    Inorder Successor | null if current node is largest

  • prev(node: Node<T>): null | Node<T>
  • rangeSearch(start: T, end: T): Node<T>[]
  • Parameters

    • start: T

      staring value for search

    • end: T

      ending value for search

    Returns Node<T>[]

    A list of nodes within range [start, end]

  • rightAncestor(node: Node<T>): null | Node<T>
  • Parameters

    • node: Node<T>

      The reference node

    Returns null | Node<T>

    The ancestor of a node with the next largest data | null if right ancestor doesn't exists

  • rightDescendant(node: Node<T>): Node<T>
  • Parameters

    • node: Node<T>

    Returns Node<T>