Medium Trees

Binary Search Tree

Receives an array of integers and builds a binary search tree: each value is placed by comparison — smaller than a node goes to its left child, larger goes to the right (duplicates are ignored). It then traverses in-order (left subtree, node, right subtree), which always visits the smallest remaining value first. Returns a new array with the values in ascending order.

Visualization

Input

Algorithm code

Custom input

Saved inputs

References