title: Finding the minimum value in a binary tree, Python
body: <p>I'm trying to write a function that returns the smallest value in the binary tree <strong>not</strong> a binary search tree.
  Here's what I've written, it's not correct.</p>
  
  <pre><code>def min(root, min_t): # min_t is the initially the value of root
      if not root:
              return min_t
  
      if root.key &lt; min_t:
              min_t = root.key
  
      min(root.left, min_t)
      min(root.right, min_t)
  
      return min_t
  </code></pre>
  
  <p>I feel I don't understand recursion very well. I can't seem to figure out when to use the return statement with a recursive call and when to not.</p>
  
  <p>Thanks for your insights!</p>
  
  <p>Here's another one I've come up with, it works, but it doesn't seem most efficient:</p>
  
  <pre><code>n = []
  def min_tree(root, n):
      if root:
          n += [(root.key)]
          min_tree(root.left, n)
          min_tree(root.right, n)
      return min(n)
  </code></pre>
  
  <p>Thoughts?</p>