What is Binary Search Tree?

Technology CommunityCategory: Data StructuresWhat is Binary Search Tree?
VietMX Staff asked 3 years ago

Binary search tree is a data structure that quickly allows to maintain a sorted list of numbers.

  • It is called a binary tree because each tree node has maximum of two children.
  • It is called a search tree because it can be used to search for the presence of a number in O(log n) time.

The properties that separates a binary search tree from a regular binary tree are:

  • All nodes of left subtree are less than root node
  • All nodes of right subtree are more than root node
  • Both subtrees of each node are also BSTs i.e. they have the above two properties

binary-search-tree