title: iterative version of recursive algorithm to make a binary tree
body: <p>Given this algorithm, I would like to know if there exists an iterative version. Also, I want to know if the iterative version can be faster.</p>
  
  <p>This some kind of pseudo-python...</p>
  
  <p>the algorithm returns a reference to root of the tree</p>
  
  <pre><code>make_tree(array a)
    if len(a) == 0
          return None;
  
    node = pick a random point from the array
    calculate distances of the point against the others
    calculate median of such distances
    node.left = make_tree(subset of the array, such that the distance of points is lower to the median of distances)
    node.right = make_tree(subset, such the distance is greater or equal to the median)
    return node
  </code></pre>