What is a BST? Whether "equal" is allowed?


  • 0
    5

    A small but important problem: what is the definition of a BST? I googled it and searched it in some command used book. There is a big difference between two definitions.

    1.The left sub-tree of a node has a key less than or equal to that of this node.
    2.The right sub-tree of a node has a key greater than to that of this node.

    Whether "equal" is allowed here? If it is allowed, the worst case is all nodes are "equal". Then at least for this problem, the O(logn) solution is wrong here.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.