A binary search tree is a binary tree that has left children less than the parent and right children greater than parent. A example is like this 7
/ \
4 9
if its child is eaqual to the parent, is it still a binary tree?
7
/ \
4 7
...全文
382打赏收藏
Binary Search Tree
A binary search tree is a binary tree that has left children less than the parent and right children greater than parent. A example is like this 7 / \ 4 9 if its child is eaqual to the parent, is it still a binary tree? 7 / \ 4 7
The answer is NOT.
No two entries in a binary search tree can have equal keys,since the
keys in the left subtrees are strictly smaller than the key in the
root,and those in the right subtree are strictly greater.
键值是排序的依据,不能相同,否则就不叫BST了。