title: create binary search tree from sorted list in R
body: <p>I am practicing recursion and tried to implement a BST from a linked list. 
  I tried to translate the solution from here to R:
  <a href="https://stackoverflow.com/questions/4235013/create-balanced-binary-search-tree-from-sorted-linked-list">Create Balanced Binary Search Tree from Sorted linked list</a></p>
  
  <p>Given a vector <code>vec</code> I want to find the BST, for example:</p>
  
  <pre><code>  0
    / \
   -3   9
   /   /
  -10  5
  
  
  vec &lt;- c(-10,-3,0,5,9)
  </code></pre>
  
  <p>This is my attempt to solve this recursively, but it does not work:</p>
  
  <pre><code>tobt &lt;- function(vec, start, end) {
    if (start &gt; end) return(NA)
    mid &lt;- start + (end - start) / 2
    left &lt;- tobt(vec, start, mid-1)
    right &lt;- tobt(vec, mid+1, end)
    return(c(left, right))
  }
  
  tobt(vec, 1, 5)
  </code></pre>
  
  <p>Where is my mistake?</p>