title: bst height algorithm in c#
body: <pre><code>class node
  {
      private float data;
      private node left;
      private node right;
  
      public int TreeHeight(int depth)
      {       
          root vL = left;//access to left data
          root vR = right;
  
          return depthOfTheTree;
      }
  }
  </code></pre>
  
  <p>The tree looks like that : <a href="https://imgur.com/EBS30rl" rel="nofollow noreferrer">http://imgur.com/EBS30rl</a></p>
  
  <p>Hello, i'm doing on one method algorithm that returns height of the tree.
  The method can only access to left and right node. Variable depth as parameter already comes with value 1 to the method itself(counting root of the tree).
  i have tried with recursive calling method but the result was not near the expected.
  My previous code is similar to code below.</p>
  
  <pre><code>public int TreeHeight(int depth)
  {
      if (left != null &amp;&amp; right == null)
          return left.TreeHeight(depth);
      else if (left == null &amp;&amp; right != null)
          return right.TreeHeight(depth);
      else
          return left.TreeHeight(depth) + right.TreeHeight(depth);
  }
  </code></pre>