title: Creating recursive methods given BinaryTree
body: <p>I'm studying for a test in a few hours, and I'm going over some practice problems but I'm really having trouble with recursion related problems. I was wondering if someone could walk me through how to do these? </p>
  
  <p>Using the <code>BinaryTree class</code> below, create the following <code>recursive</code> methods: </p>
  
  <ul>
  <li><code>sum()</code> – returns the sum of all values in the BinaryTree. </li>
  <li><code>countGreaterThan(int)</code> – returns the number of nodes that have values greater than the specified integer. </li>
  <li><code>isValidSearchTree()</code> – returns true if the Binary Tree is a valid search tree and false otherwise. </li>
  </ul>
  
  <p>I get the basic premise of how to create these functions like for example, for the sum function it'd usually go something like:</p>
  
  <pre><code>int sum = 0
  for(int i; i&lt;binaryTree.size(); i++){
      sum += binaryTree[i]
  }
  </code></pre>
  
  <p>Or something similar. But I don't really know how to apply these concepts to a <code>BinaryTree</code> with <code>nodes</code> and make them <code>recursive</code> as well? The code I'm provided with is given below.</p>
  
  <pre><code>public class BinaryTree {
   private int data;
   private BinaryTree leftChild;
   private BinaryTree rightChild;
  
   public BinaryTree(int val) {
       data = val;
       leftChild = null;
       rightChild = null;
    }
  
    // Get methods
   public int getData() { return data; }
   public BinaryTree getLeftChild() { return leftChild; }
   public BinaryTree getRightChild() { return rightChild; }
  
   // Set methods
   public void setData(int val) { data = val; }
   public void setLeftChild(BinaryTree left) { leftChild = left; }
   public void setRightChild(BinaryTree right) { rightChild = right; }
  }
  </code></pre>