Is This a Binary Search Tree?

  • + 2 comments

    You should really explain how you generate the tree from input, so people can test their solutions locally as well.

    • + 1 comment

      I must agree. Not knowing how the tree was constructed based on the input - how it sets the root etc, made it difficult for me. Perhaps it was explained in a previous challenge somewhere but I did not find that.

      • + 0 comments

        Do you know how to do this?

    • + 4 comments

      Could anyone take some time and help me/others to understand the construction of the tree for the testcase.

      2

      1 2 4 3 5 6 7

      Is the below correct? But the expected output is NO. So just like to check with you all.

      1
          2
              4
          3       5
                      6
                          7
      
      This is a valid BST right?
      
      • + 0 comments

        Yes it is.

      • + 1 comment

        if tree like this:
        -----------3
        ------2---------5
        --1------4----6----7

        this tree is not a BST tree
        
        • + 0 comments

          no

      • + 0 comments

        first perform the required rotation buddy

      • + 0 comments

        They have built tree differently. Hence we have to use min max logic