sortedArrayToBST - Definition for binary tree public class TreeNode cfw int val TreeNode left TreeNode right TreeNode(int x cfw val = x public class

sortedArrayToBST - Definition for binary tree public class...

This preview shows page 1 out of 1 page.

/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class sortedArrayToBST { TreeNode sortedArrayToBST(int arr[], int start, int end) { if (start > end) return null; // same as (start+end)/2, avoids overflow. int mid = start + (end - start) / 2;
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Spring '14
  • Sort

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes