treebinary-treebinary-search-tree

can a binary search tree has two branches only?


According to GeeksForGeeks, a binary tree is a BST when:

The left subtree of a node contains only nodes with keys lesser than the node’s key.
The right subtree of a node contains only nodes with keys greater than the node’s key.
The left and right subtree each must also be a binary search tree.

I wonder if a tree like following can still be considered as BST?

     3
   2   4
 1       5
0

Solution

  • In a word - yes. There is no requirement that the tree be "full" (i.e., every node should have exactly two children.