title: How i can convert this input String to a BST(Binary-search-tree)-JAVA?
body: <p>I have to return true or false if an input String is a valid or not valid BST(Binary Search Tree).</p>
  
  <p>The problem is that i have in input an atypical string with this "pattern" : ( ROOT (LEFT , RIGHT ) );
  there is a space between every element, ROOT is the central node, LEFT the left one and RIGHT the right one. If a node is null is encoded like "-",a leaf is encoded with the numeric value, if a node have some child is encode in this way: For example B have two child (D at left,E at right) so ( A ( B ( D , E ) , C ) )</p>
  
  <p>I have tried to split the string in an array of String but i have no idea how to populate the tree and at the same time check if it is a BST.How i can populate the tree with this String?</p>
  
  <p>I would try with this algorithm:</p>
  
  <p>//How i split the String </p>
  
  <pre><code> String[] albero = b.readLine().split("\\,|\\(|\\)|\\-");
  </code></pre>
  
  <p>//How i would check if is a BST</p>
  
  <pre><code>public class IsBST {
  
      public boolean isBST(Node root){
          return isBST(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
      }
  
      private boolean isBST(Node root, int min, int max){
          if(root == null){
              return true;
          }
          if(root.data &lt;= min || root.data &gt; max){
              return false;
          }
          return isBST(root.left, min, root.data) &amp;&amp; isBST(root.right, root.data, max);
      }
  </code></pre>
  
  <p>Example:</p>
  
  <blockquote>
    <p>INPUT 1: ( 100 ( 19 ( 17 ( 2 , 7 ) , 3 ) , 36 ( 25 , 1 ) ) )</p>
    
    <p>OUTPUT 1: false</p>
    
    <p>INPUT 2: ( 8 ( 3 ( 1 , 6 ( 4 , 7 ) ) , 10 ( - , 14 ( 13 , - ) ) ) )</p>
    
    <p>OUTPUT 2: true</p>
  </blockquote>