首页 文章

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

提问于
浏览
2

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

3
      /   \
     2     4
   /   \
  1     3

我不确定的原因是因为:

  • 树中有重复项(3)

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

2 回答

  • 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
    
  • 0

    是的,左子树's nodes'键值小于节点's key value; and the right subtree' s节点' key value is greater then the node'的键值; [这里是binary_serch_tree wiki]:http://en.wikipedia.org/wiki/Binary_search_tree

相关问题