title: how does the following code works? finding the depth of the tree?
body: <p>please explain the working of following code? i am unable to get the recursion.</p>
  
  <pre><code>int depth(struct tree *q)
  { 
      int h1,h2;
      if(q==NULL)
         return 0;
      else
      {
         h1=depth(q-&gt;left);
         h2=depth(q-&gt;right);
      }
      return (max(h1,h2) +1 );
  }
  </code></pre>
  
  <p>how does recursion work in the above code? how does h1 and h2 get there value?</p>