# What is a Binary Search Tree?

In the world of computer science and data structure, a binary search tree is a famous terminology, also popular as an ordered or sorted binary tree.

A binary search tree attempts to organise the components in some order. The value of the left node in a Binary search tree should be less than the root node, while the value of the right node should be greater.

**NOTE:** We’ll apply this rule recursively to the root’s left and right subtrees.

## Complexities of Binary Search Tree

We will discuss the two complexities here:

- Time complexity
- Space complexity

## ● **Binary search tree time complexity: **The time complexity of the binary search tree is O(log n) time. Here n represents the number of nodes. Also, when it comes to the worst-case condition, the time complexity is zero (n). The tree gets unstable in this situation.

## ● **Binary search tree space complexity:** The space complexity of a is O. (n).

## Types of Traversals in Binary Search Tree

## There are three ways through which a binary search tree can traverse:

## 1. **Pre-order traversal:** When it comes to pre-order, we proceed with the root node to the left subtree, and after that, we move towards the right subtree.

**In-order traversal:**In in-order traversal, we start at the left node, then travel to the root node, and finally to the right node.**Post-order traversal:**In post-order traversal, we can start with the left child node, then the right child node, and finally, the current node.

## Application of Binary Search Tree

- Indexing and multi-level indexing are performed using a binary search tree.
- They can also implement a range of search algorithms.
- It facilitates organising a data stream.

## Operation in Binary Search Tree

- Search operation
- Insertion operation
- Deletion operation

**Search operation:**In a binary search tree, we can use this operation to find the location of a particular component.

**Insertion operation:**This feature enables us to place a node or element in the correct location.

**Deletion operation:**A deletion operation is used when we need to remove a certain node or item from the binary search tree.

## Advantages of Binary Search Tree

- When balanced, the binary search tree is quick in terms of insertion and deletion.
- It is quite effective, and the code is simpler than that of link lists.

## Disadvantages Binary Search Tree

- The shape of the tree is determined by the insertion sequence, and it can degenerate.
- Searching processes take much longer in binary search trees.

## GATE Aspirants – Do Not Forget to Cover All the Important Topics Like Binary Search Tree

Are you preparing for the GATE computer science exam? If you answered yes, you must pay close attention to the details and cover all of the technical core themes and subtopics. There are many additional areas that every applicant should be familiar with and learn, such as arrays, data structures, programming, algorithms, coding, operating systems, databases, stacks in data structures, compiler design, and much more. If you are excited about this exam and want to succeed in the future by passing it, you must pay attention to every detail.

All the best to all the GATE computer science aspirants!