recategorized by
1,977 views

1 Answer

Best answer
2 votes
2 votes

We can do it in O(nlogn) time.

Step1:->Sort the array.O(nlogn) 

Step2:->Construct Balanced Bst from Sorted array O(n) time.

http://www.geeksforgeeks.org/sorted-array-to-balanced-bst/

So max(step1,step2)= O(nlogn) is ans.

Note:->

1.As here making bst is concern we can always make balanced bst .

2.Here the data is already stored in an array in sorted manner and we are making balanced bst ;So skewed array case will never occur which makes O(n2).

selected by

Related questions

0 votes
0 votes
1 answer
3
aditi19 asked Oct 1, 2018
618 views
what are the applications of optimal binary search tree?
1 votes
1 votes
0 answers
4
Anjan asked Jan 9, 2018
335 views
Find number of BST's possible with 6 nodes numbered 1,2,3,4,5 and 6 having 6 as root and height of 4 ?please explain in detail ...