Difference between binary tree and binary search tree

Neel picture Neel · Jun 17, 2011 · Viewed 222.4k times · Source

Can anyone please explain the difference between binary tree and binary search tree with an example?

Answer

user541686 picture user541686 · Jun 17, 2011

Binary tree: Tree where each node has up to two leaves

  1
 / \
2   3

Binary search tree: Used for searching. A binary tree where the left child contains only nodes with values less than the parent node, and where the right child only contains nodes with values greater than or equal to the parent.

  2
 / \
1   3