Hello guys,
your definition of a binary search tree allows for duplicates at both sides, so you consider
9 / \ 9 9
a valid BST. I haven’t seen such definition before, most books and resources either disallow duplicates at all or allow duplicates only on one side (either left or right). Allowing duplicates on both sides makes it difficult to find all elements of some key or re-balance such a tree.
This also involves solution to 15.1 where you check:
Integer.compare(tree.data, lower) < 0 || Integer.compare(tree.data, upper) > 0
which in my opinion should be adjusted and include either >=
or <=
.