Binary Search Tree

A Binary Search Tree (BST) is a tree in which all of the nodes have the following properties:

The key of the left sub-tree has a lower value than the key of its parent (root) node.

The key of the right sub-tree is greater than or equal to the key of its parent (root) node.

As a result, BST separates all of its subtrees into two segments: the left subtree and the right subtree, and may be characterized as :

left_subtree (keys) < node (key) ≤ right_subtree (keys)

BST is a set of nodes that are structured in such a way that they retain BST attributes. Each node has a key and a value associated with it. The required key is compared to the keys in BST when searching, and if found, the related value is obtained.

Following is a pictorial representation of BST −

Binary Search Tree

Basic Operations

Following are the basic operations of a tree −

  • Search − Searches an element in a tree.
  • Insert − Inserts an element in a tree.
  • Pre-order Traversal − Traverses a tree in a pre-order manner.
  • In-order Traversal − Traverses a tree in an in-order manner.
  • Post-order Traversal − Traverses a tree in a post-order manner.


Define a node having some data, and references to its left and right child nodes.

Search Operation

When looking for an element, begin your search at the root node. If the data is less than the key value, look for it in the left subtree. Otherwise, look for a said element in the appropriate subtree. For each node, use the same algorithm.

Insert Operation

When inserting an element, first determine its suitable placement. Begin your search at the root node, and if the data is less than the unique key, go to the left subtree and enter the data. Otherwise, find an empty position in the appropriate subtree and insert the data.


1,738 thoughts on “Binary Search Tree”

  1. Pingback: 2unsteady

  2. Thank you for every one of your work on this blog. My daughter really likes conducting research and it’s really obvious why. We all hear all about the lively tactic you render useful tactics on your web site and in addition inspire contribution from some others on the content and my princess is truly becoming educated a lot. Have fun with the rest of the year. You are performing a really good job.

  3. Good day! I know this is kind of off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having difficulty finding one? Thanks a lot!

  4. Unlock the logic of data organization with the concept of a BINARY SEARCH TREE. Just as this structure simplifies data retrieval, envision the efficiency of BARGAIN With AI Chat Bot streamlining your online shopping. Navigate the complexities of deals effortlessly, ensuring a logical and intelligent approach to finding the best bargains.

  5. I’m still learning from you, but I’m improving myself. I absolutely liked reading all that is written on your website.Keep the information coming. I liked it!

  6. I have not checked in here for some time as I thought it was getting boring, but the last few posts are good quality so I guess I will add you back to my everyday bloglist. You deserve it my friend 🙂

  7. Thank you for the sensible critique. Me and my neighbor were just preparing to do a little research on this. We got a grab a book from our local library but I think I learned more from this post. I am very glad to see such wonderful information being shared freely out there.

  8. I like what you guys are up too. Such smart work and reporting! Keep up the superb works guys I’ve incorporated you guys to my blogroll. I think it’ll improve the value of my site 🙂

  9. I have been surfing on-line greater than three hours today, but I never found any attention-grabbing article like yours. It is beautiful price enough for me. Personally, if all webmasters and bloggers made good content as you did, the net might be a lot more useful than ever before.