title: minimum element of binary tree
body: <p>I have implemented functions to find the max and min element of the binary tree. But I am getting the wrong output for it. </p>
  
  <p>Function to find the maximum of the binary tree. </p>
  
  <pre><code>int FindMax(struct TreeNode *bt)
  {
  //get the maximum value of the binary tree... 
  int max;
  //get the maximum of the left sub-tree. 
  int left;
  //get the maximum of the right sub-tree.
  int right;
  //get the root of the current node.
  int root;
  
          if(bt!=NULL)
          {
  
                  root=bt-&gt;data;
                  //Call the left tree recursively....
                  left=FindMax(bt-&gt;leftChild);
  
                  //Call the right tree recursively...
                  right=FindMax(bt-&gt;rightChild);
  
                  if(left &gt; right)
                  {
                          max=left;
                  }
                  else
                  {
                          max=right;
                  }
                  if(max &lt; root)
                  {
                          max=root;
                  }
  
          }
  
  return max;
  }
  </code></pre>
  
  <p>Function to find the min of binary tree. </p>
  
  <pre><code>int FindMin(struct TreeNode *bt)
  {
  //get the minimum value of the binary tree... 
  int min;
  //get the minimum of the left sub-tree. 
  int left;
  //get the minimum of the right sub-tree.
  int right;
  //get the root of the current node.
  int root;
          if(bt!=NULL)
          {
  
                  root=bt-&gt;data;
                  //Call the left tree recursively....
                  left=FindMin(bt-&gt;leftChild);
  
                  //Call the right tree recursively...
                  right=FindMin(bt-&gt;rightChild);
  
                  if(left &lt; right)
                  {
                          min=left;
                  }
                  else
                  {
                          min=right;
                  }
                  if(min &gt; root)
                  {
                          min=root;
                  }
  
          }
  
  return min;
  }
  </code></pre>
  
  <p>Output : 
  The maximum of tree 32767</p>
  
  <p>The minimum of tree 0</p>