Binary Search Tree in Kotlin | Data Structures

The 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 a 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 the left subtree are less than the root node
  • All nodes of the right subtree are more than the root node
  • Both subtrees of each node are also BSTs i.e. they have the above two properties


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 does 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 has.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions