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 - All values of left sub tree < node-> val All values of right sub tree > node->val Example - 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 .

Feb 14, 2025 - 11:35
 0
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 .