title: Parallelize Convert Sorted Array to Binary Search Tree Function
body: <p>I am trying to parallelize my Convert Sorted Array to BST program in Java. Because my function runs in Divide and Conquer manner, I believe it is parallelizable, but have been stuck with the implementation. It will be very helpful if you guys can tell me how to apply <strong>threads</strong> in here.</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>// Definition for a binary tree node.
  public class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode(int x) { val = x; }
  }
  
  public class Solution {
      public TreeNode sortedArrayToBST(int[] nums) {
          if (nums == null) {
              return null;
          }
          return sortedArrayToBST(nums, 0, nums.length - 1);
      }
  
      private TreeNode sortedArrayToBST(int[] nums, int start, int end) {
          if (start &gt; end) {
              return null;
          }
  
          int mid = start + (end - start) / 2;
          TreeNode node = new TreeNode(nums[mid]);
          node.left = sortedArrayToBST(nums, start, mid - 1);
          node.right = sortedArrayToBST(nums, mid + 1, end);
  
          return node;
      }
  }
  </code></pre>