Understanding construction from an unsorted array


Constructing a binary search tree from an unsorted array of values is easy. It is not always the best method, but it is one of the easiest.

Algorithm

To construct a binary search tree from a given sequence, we start with an empty binary tree and insert all the elements in the sequence into it individually using the standard BST insert (values smaller than the current node go to the left subtree, values greater than or equal go to the right subtree).

1 of 7

Insert values one at a time in binary search tree

Liking the course? Check our discounted plans to continue learning.