Binary Search Tree

Binary search tree is a data structure that quickly allows us 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-kotlin

Binary Search Tree - Visual of insertion Operation :

Subscribe to my youtube channel :


Operations on kotlin Binary Search Tree

Searching :

Finding the location of some specific element in a binary search tree.

Insertion :

Adding a new element to the binary search tree at the appropriate location so that the property of BST do not violate.

Deletion :

Deleting some specific node from a binary search tree. However, there can be various cases in deletion depending upon the number of children, the node have.

About Author

This article is written by Pavan, who is serving notice period in an MNC, Bangalore. He thought, let the articles speak rather than his image. He is also the same person who created the reporter for Protractor Jasmine

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions