title: How to create a Decision Tree from a Collection of decisions?
body: <p>I'm asked to make a constructor for a Decision Tree class, but I have no idea how to approach it.</p>
  
  <p><strong>The question asks:</strong></p>
  
  <p>Write a constructor for the Decision Tree class, which takes in a sorted array of
  instances, and constructs recursively a tree that splits the data until all leaves are pure. .</p>
  
  <p>Here is the Decision Tree class I have to program:</p>
  
  <pre><code>package DecisionTree;
  
  public class DecisionTree {
  
  public DecisionTree(Instance[] instances) {
  
  // code goes here
  }
  
  public void prune() {
  // code goes here
  }
  
  public boolean classify(double input) {
  // code goes here
  }
  
  public void print() {
  // code goes here
   }
  }
  </code></pre>
  
  <p>I am also provided with these methods:</p>
  
  <p>First:</p>
  
  <pre><code>package DecisionTree;
  
  public class DTNode {
  
      Instance[] a;
      double testValue;
      DTNode left, right;
  
      // code goes here
  }        
  </code></pre>
  
  <p>Second:</p>
  
  <pre><code>package DecisionTree;
  
  public class Instance {
  
      double attribute;
      boolean label;
  
      public Instance(double a, boolean c) {
      attribute = a;
      label  = c;
      }
  
      public double getAttribute() {
      return attribute;
      }
  
      public void setAttribute(double a) {
      attribute = a;
      }
  
      public boolean getLabel() {
      return label;
      }
  
      public void setLabel(boolean c) {
      label = c;
      }
  }
  </code></pre>