Overview

A binary search tree implemented in JavaScript. The constructor sorts an input array, removes duplicate values, and builds a balanced tree.

Operations

  • Insert, delete, and find values.
  • Measure tree height and node depth.
  • Traverse in level order, pre-order, post-order, or in-order.
  • Check balance and explicitly rebuild an unbalanced tree.

Traversal methods accept a callback for each value. The repository includes a basic usage example and a randomised driver for exploring how insertions affect balance. Rebalancing is an explicit operation, rather than an automatic step after every insertion.