$this->right = new BST();
    }
    /**
     * Balances this node.
     * Does nothing in this class.
     */
    protected function balance()
    {
    }
    /**
     * Main program.
     *
     * @param array $args Command-line arguments.
     * @return integer Zero on success; non-zero on failure.
     */
    public static function main($args)
    {
        printf("BinarySearchTree main program.\n");
        $root = new BST();
        foreach ($args as $row) {
            $root->insert($row);
        }
        return $root;
    }
}
$b_tree = array(50, 3, 10, 5, 100, 56, 78);
$root = BST::main($b_tree);
echo $root->findMax();
$root->delete(100);
printf("after delete:\n");
echo $root->findMax();
示例#2
0
        $this->key = $obj;
        $this->left = new BST();
        $this->right = new BST();
    }
    /**
     * Balances this node.
     * Does nothing in this class.
     */
    protected function balance()
    {
    }
    /**
     * Main program.
     *
     * @param array $args Command-line arguments.
     * @return integer Zero on success; non-zero on failure.
     */
    public static function main($args)
    {
        printf("BinarySearchTree main program.\n");
        $root = new BST();
        foreach ($args as $row) {
            $root->insert($row);
        }
        return $root;
    }
}
$root = BST::main(array(50, 3, 10, 5, 100, 56, 78));
echo $root->findMax();
$root->delete(100);
echo $root->findMax();