Is This a Binary Search Tree?

  • + 4 comments

    Consider the below 2 types of trees, you will know where you went wrong.

    Case 1 :

       20
      /  \
     10   2
    

    Case 2:

       18
      /  \
     8    20
         /  \
        10  30
    
    • + 2 comments

      Alright I got it we have to find the minimum from left sub tree and the maximum from the right one Thanks!

      • + 2 comments

        Yes correct !

        • + 0 comments

          Isn't it that all nodes in left tree should be less than root and right should be greater than root. Than why we need to find min and max.

      • + 0 comments

        Is it not the other way? minimum from right sub tree must be greater than root and maximum from left subtree must be less than root

    • + 0 comments

      Got it. thanks a lot.

    • [deleted]Challenge Author
      + 0 comments

      Thanks for case 2 visualization, this explains why my code failed a bunch of test cases.

    • + 0 comments

      Can anyone please tell me what's wrong in his code? What t understand from these two test-cases?