src/Datastructure/Graph/Tree/BinarySearchTree.php
public static function createFromArrayWithMinimumHeight(?array $array): ?BinarySearchTree {
        if (null === $array) {
            return null;
        }
        $tree = new BinarySearchTree();
        if (0 === \count($array)) {
            return $tree;
        }
        $sort = new MergeSort();
        $array = $sort->sort($array);
        $root = BinarySearchTree::_createFromArrayWithMinimumHeight($array, 0, \count($array) - 1);
        $tree = new BinarySearchTree();
        $tree->setRoot($root);
        return $tree;
    }
public static function createFromArrayWithMinimumHeight(?array $array): ?BinarySearchTree {
        if (null === $array) {
            return null;
        }
        $tree = new BinarySearchTree();
        if (0 === \count($array)) {
            return $tree;
        }
        $sort = new MergeSort();
        $array = $sort->sort($array);
        $root = BinarySearchTree::_createFromArrayWithMinimumHeight($array, 0, \count($array) - 1);
        $tree = new BinarySearchTree();
        $tree->setRoot($root);
        return $tree;
    }
public static function createFromArrayWithMinimumHeight ( ? array $ array ) : ? BinarySearchTree { if ( null === $ array ) { return null ; } $ tree = new BinarySearchTree ( ) ; if ( 0 === \ count ( $ array ) ) { return $ tree ; } $ sort = new MergeSort ( ) ; $ array = $ sort -> sort ( $ array ) ; $ root = BinarySearchTree :: _createFromArrayWithMinimumHeight ( $ array , 0 , \ count ( $ array ) - 1 ) ; $ tree = new BinarySearchTree ( ) ; $ tree -> setRoot ( $ root ) ; return $ tree ; }
converts an array to a BST with minimum height.

@param array|null $array
@return BinarySearchTree|null
converts an array to a BST with minimum height .