Skip to main content

latest
Works with
It is unknown whether this package works with Node.js, Deno, Browsers, Cloudflare Workers, Bun
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score58%
Published2 years ago (0.215.0)

Classes

c
BinarySearchTree<T>(compare?: (
a: T,
b: T
) => number
)

An unbalanced binary search tree. The values are in ascending order by default, using JavaScript's built-in comparison operators to sort the values.

  • _size: number
    No documentation available
  • clear(): void

    Removes all values from the binary search tree.

  • find(value: T): T | null

    Returns node value if found in the binary search tree.

  • findNode(value: T): BinarySearchNode<T> | null
    No documentation available
  • from<T>(collection: ArrayLike<T> | Iterable<T> | BinarySearchTree<T>): BinarySearchTree<T>

    Creates a new binary search tree from an array like or iterable object.

  • insert(value: T): boolean

    Adds the value to the binary search tree if it does not already exist in it. Returns true if successful.

  • insertNode(
    Node: BinarySearchNode,
    value: T
    ): BinarySearchNode<T> | null
    No documentation available
  • isEmpty(): boolean

    Checks if the binary search tree is empty.

  • lnrValues(): IterableIterator<T>

    Returns an iterator that uses in-order (LNR) tree traversal for retrieving values from the binary search tree.

  • lrnValues(): IterableIterator<T>

    Returns an iterator that uses post-order (LRN) tree traversal for retrieving values from the binary search tree.

  • lvlValues(): IterableIterator<T>

    Returns an iterator that uses level order tree traversal for retrieving values from the binary search tree.

  • max(): T | null

    Returns the maximum value in the binary search tree or null if empty.

  • min(): T | null

    Returns the minimum value in the binary search tree or null if empty.

  • nlrValues(): IterableIterator<T>

    Returns an iterator that uses pre-order (NLR) tree traversal for retrieving values from the binary search tree.

  • remove(value: T): boolean

    Removes node value from the binary search tree if found. Returns true if found and removed.

  • removeNode(node: BinarySearchNode<T>): BinarySearchNode<T> | null

    Removes the given node, and returns the node that was physically removed from the tree.

  • rnlValues(): IterableIterator<T>

    Returns an iterator that uses reverse in-order (RNL) tree traversal for retrieving values from the binary search tree.

  • root: BinarySearchNode<T> | null
    No documentation available
  • rotateNode(
    node: BinarySearchNode<T>,
    direction: Direction
    ): void
    No documentation available
  • size(): number

    The amount of values stored in the binary search tree.

Type Aliases

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/data-structures

Import symbol

import * as mod from "@std/data-structures/binary_search_tree";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/data-structures/binary_search_tree";