Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void sortedArrayToBST(AVLTree t, int arr[], int start, int end) {
- /* Base Case */
- if (start > end) {
- return;
- }
- /* Get the middle element and make it root */
- int mid = (start + end) / 2;
- t.insert(arr[mid], false);
- /* Recursively construct the left subtree and make it
- left child of root */
- sortedArrayToBST(t, arr, start, mid - 1);
- /* Recursively construct the right subtree and make it
- right child of root */
- sortedArrayToBST(t, arr, mid + 1, end);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement