1.

What is the time complexity of the code that uses self balancing BST for determining the number of inversions in an array?(a) O(n^2)(b) O(n)(c) O(log n)(d) O(n log n)I'd like to ask this question from Arrays Types topic in division Arrays Types of Data Structures & Algorithms IThis question was addressed to me in examination.

Answer»

Right answer is (d) O(n log n)

Easiest EXPLANATION - When a self BALANCING BST LIKE an AVL tree is USED to calculate the number of inversions in an array then the time complexity is O(n log n) as AVL insert takes O(log n) time.



Discussion

No Comment Found

Related InterviewSolutions