Sunday, November 22, 2015

108 Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.

Thoughts:
Make the number in the middle of the array the root of the BST, then construct the sub trees recursively with binary search.

Python Codes:

No comments:

Post a Comment