# What is a Binary Search Tree?

In the world of computer science a tree looks like this! 😆

If you are given a list of numbers like [2, 8, 12, 17, 22, 29, 32] and suppose you need to find the closest number to a given target value, then you can use a BST.

off course you know BST is a Data Structure & Binary means “two things”. How does it look on paper?

`         17        /  \      8     29     / \   /  \    2   12 22  32`

Looks like a Pyramid, right? then why everyone is calling it a Tree? may be due to the branches. idk! 🤷‍♂️

the same tree can also be represented as below

`        2         \          8           \            12             \              17               \                22                 \                  29                   \                    32`

looks like a Staircase! Geniuses are saying that this is also a tree!

Now you may be thinking, why do we need to represent data in a BST? We have linked list, right?

You are correct. If the input data is already sorted, using a Binary Search Tree (BST) might not be the best choice in terms of efficiency and balance. This is because a sorted input can lead to the creation of a degenerate BST, which essentially becomes a linked list.

--

--

Software Engineer, Loves to design and deploy Web apps and Mobile Apps. Entrepreneur by heart and in a journey to build some thing useful for the world.