什么是有效的二叉搜索树?

时间:2015-01-16 12:02:58

标签: binary-tree binary-search-tree

我刚刚想出了一个我正在研究的算法的例子,并意识到我不明白以下二叉树是否是二叉搜索树:

        3
      /   \
     2     4
   /   \
  1     3

我不确定的原因是:

  • 树(3)
  • 中有重复项

左子树中所有值的二叉搜索树的规则是否小于根?

2 个答案:

答案 0 :(得分:2)

这是二元搜索树..

1) If you traverse it in IN-ORDER you will get the sorted list
2) Every element on the left node is less than root node (in value)
3) As far as the duplication is concerned, it is okay, since the in-order traversal will return 1,2,3,3,4 

答案 1 :(得分:0)

是的,左子树节点的键值小于节点的键值;并且右子树的节点的键值大于节点的键值; [这里是binary_serch_tree wiki]:http://en.wikipedia.org/wiki/Binary_search_tree