1.

What is the best case time complexity of the binary tree sort?(a) O(n)(b) O(nlogn)(c) O(n^2)(d) O(logn)The question was posed to me in final exam.The query is from Sorting topic in chapter Sorting of Data Structures & Algorithms II

Answer» CORRECT OPTION is (b) O(nlogn)

Easy explanation - The best case OCCURS when the BST is BALANCED. So, when tree is balanced we require O(nlogn) time to build the tree and O(N) time to traverse the tree. So, the best case time complexity of the binary tree sort is O(nlogn).


Discussion

No Comment Found

Related InterviewSolutions