How to avoid Integer Overflow when comparing two node valued in BST?

For example, if here are one BST as:

[Integer.MIN_VALUE, Integer.MIN_VALUE]

If I want to compare if the left child node is smaller or equal to parent nod – 1, the value gonna be overflow.
In this case, don’t use Integer.MIN_VALUE, use null as the default instead.

Here is an example about using null as comparison threshold.

Leave a Reply