c********p 发帖数: 1969 | 1 BST 定义是left可以等于root,但right必须大于root。
解recovery bst的时候,不考虑相等么?只有大于了才算它错,可是当root和right相
等,这个时候,也是错的吧! |
J****3 发帖数: 427 | 2 In computer science, a binary search tree (BST), sometimes also called an
ordered or sorted binary tree, is a node-based binary tree data structure
which has the following properties:[1]
The left subtree of a node contains only nodes with keys less 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 must each also be a binary search tree.
There must be no duplicate nodes.
Wiki |
c********p 发帖数: 1969 | 3 是哦,我刚看了一下,确实这么定义的,都没有相等的情况。
可是。。。cc150上边这道题,它这样说的哦。。。。
node'
【在 J****3 的大作中提到】 : In computer science, a binary search tree (BST), sometimes also called an : ordered or sorted binary tree, is a node-based binary tree data structure : which has the following properties:[1] : The left subtree of a node contains only nodes with keys less 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 must each also be a binary search tree. : There must be no duplicate nodes. : Wiki
|
J****3 发帖数: 427 | 4 那上面错了吧。 还是以
• every node has a key
• every node’s key is
node
x
larger than all keys in its left subtree smaller than all
keys in its right subtree 这样吧 |
c********p 发帖数: 1969 | 5 嗯嗯,应该错了。。
误导我了。。。
【在 J****3 的大作中提到】 : 那上面错了吧。 还是以 : • every node has a key : • every node’s key is : node : x : larger than all keys in its left subtree smaller than all : keys in its right subtree 这样吧
|
h*****a 发帖数: 1718 | 6 一个BST里面有没有相同的key都不一定的,要看具体情况,没必要纠结。具体的问题可
以有就有,都unique也正常。
【在 J****3 的大作中提到】 : 那上面错了吧。 还是以 : • every node has a key : • every node’s key is : node : x : larger than all keys in its left subtree smaller than all : keys in its right subtree 这样吧
|