title: Binary Tree Height Function
body: <p>I'm working on a function to find the height of a binary search tree. I found a method that seems like it should work, but I keep getting this error, and I don't know whats wrong with it: Unhandled exception at 0x00903417 in PA5.exe: 0xC0000005: Access violation reading location 0x00000004.</p>
  
  <p>Here are my height functions...</p>
  
  <pre><code>template &lt;class T&gt;
  int BST&lt;T&gt;::height()
  {
  
      return displayHeight(mRootNode);    
  
  }
  
  template &lt;class T&gt;
  int BST&lt;T&gt;::displayHeight(BST&lt;T&gt; *node)
  {
      if (node = NULL)
      {
          return 0;
      }
  
      int left = displayHeight(node-&gt;mLeft);
      int right = displayHeight(node-&gt;mRight); 
  
      if (left &gt; right)
          return 1 + left;
      else
          return 1 + right;
  }
  </code></pre>
  
  <p>This is the implementation in the main function...</p>
  
  <pre><code> cout &lt;&lt; endl &lt;&lt; "height: " &lt;&lt; tree.height();
  </code></pre>
  
  <p>If I should include anything else, let me know. Thanks!</p>