BST Beginners problem

  • -10^9 ≤ x ≤ 10^9
  • 1 ≤ position( x ) ≤ 2^32 - 1
    what does these limits indicate in BST problem of beginners

The First Constraint says that value of x would range between -10^9 to 10^9 .

The Second Constraint says that position of x would lie between 1 to 2^32 -1 .

Actually what would be affect of these constraints on code means how code would satisfy them… if you could illustrate with an example

Um look…Constraints help when you design an algorithm, and selection of data type. In this particular case of BST Operation if you look. at the position constraint, it means that you can’t use “int” datatype, you either need “unsigned int” or “long” as datatype.

for this question i don’t think it’s of much use, as you can simply choose “long” as datatype, and all operation on BST takes O(logn) time

But for most questions, it helps to analyze Time Complexity of Algorithm, like example you can’t pass a question with constraint size of 10^6 with an O(n^2) algorithm, for that you either need an O(n) or O(nlogn) algorithm.