Skip to main content

Binary Search Tree

A ordered tree where each node's left subtree contains smaller values and the right subtree contains larger values.

Interactive Visualization

The visualization below shows tree traversal on a sample BST structure built from [3, 7, 2, 9, 16, 11, 4].

Loading visualization…

Usage

src/sample/binarysearchtree.ts
import { BinarySearchTree } from 'athro';

const bst = new BinarySearchTree<number>();
bst.insert(3);
bst.insert(7);
bst.isPresent(7);

Available Methods

MethodsDescriptionSyntax
insertAdd a value to the BSTbst.insert(value)
isPresentCheck if a value existsbst.isPresent(value)
getRootAccess the root node for traversalsbst.getRoot()