DEV Community

Mujahida Joynab
Mujahida Joynab

Posted on

What is Binary Search Tree

It is a combination of
Binary Search + Binary Tree

A binary tree where we can do binary search .
It can have maximum 2 child .

What is binary search ?
At start point we see if the value is equal to the mid value . If the value is greater than the mid value we used to search at right . Else at left if it is less then the mid value .

We follow two condition -

  1. All values of left sub tree < node-> val
  2. All values of right sub tree > node->val

Example -
Image description

Here all values of left nodes from root are less than the root and right side value from the root are greater than the root .

So , The left sub tree have to be less than the root node
and the right sub tree have to be greater than the root node .

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay