title: Building a balanced binary search tree
body: <p>Is there a method to build a balanced binary search tree?</p>
  
  <p>Example:</p>
  
  <pre><code>1 2 3 4 5 6 7 8 9
  
         5
        / \
       3   etc
      / \
     2   4
    /
   1
  </code></pre>
  
  <p>I'm thinking there is a method to do this, without using the more complex self-balancing trees. Otherwise I can do it on my own, but someone probably have done this already :)</p>
  
  <hr>
  
  <p>Thanks for the answers! This is the final python code:</p>
  
  <pre><code>def _buildTree(self, keys):
      if not keys:
          return None
  
      middle = len(keys) // 2
  
      return Node(
          key=keys[middle],
          left=self._buildTree(keys[:middle]),
          right=self._buildTree(keys[middle + 1:])
          )
  </code></pre>