Difference between binary tree and binary search tree

后端 未结 12 1673
情深已故
情深已故 2020-11-29 14:44

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

12条回答
  •  生来不讨喜
    2020-11-29 15:08

    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
    

提交回复
热议问题