title: Making a binary search tree from a sorted array
body: <p>Let's say I have a sorted array with [1,2,3,4,5], it should become a binary search tree with this array as its output: [4,2,5,1,3]  (the brackets below represent the indices)</p>
  
  <pre><code>                               4 (0) 
                                /    \
                             2 (1)    5 (2)
                              /  \
                           1 (3)  3 (4)
  </code></pre>
  
  <p>While doing some research online, I found a link on this site that I could use to get this: <a href="https://stackoverflow.com/questions/19399747/insert-sorted-array-into-binary-search-tree">Insert sorted array into binary search tree</a></p>
  
  <p>I wanted to convert this to Python 3 without the use of any classes. This is what I have so far, but I'm stuck. </p>
  
  <pre><code>def bstlist(arr,start,end):
      newlst = []
      #start = arr[0]
      #end = arr[-1]
      if start &gt; end:
          return [] #null
  
      mid = start + (end - start) / 2
      newlst = arr[mid]
  </code></pre>
  
  <p>I'm particularly confused about how to implement three lines of code in the Java implementation in Python:</p>
  
  <pre><code>TreeNode node = new TreeNode(arr[mid]);
  node.left = sortedArrayToBST(arr, start, mid-1);
  node.right = sortedArrayToBST(arr, mid+1, end);
  </code></pre>
  
  <p>How would I go about implementing them in Python ? And is there any other way to solve this in Python than the one listed in the link?</p>