0 0 votes Let an array A has n elements, where each element is a natural number. it is known that the array A has exactly r number of inversions. now every element int he array is made negative. then the time complexity of the most efficient algorithms which computes the inversion pairs in the modified array A will be? Given answer: O(1) My answer: O(n logn), because they have asked the inversion pairs, not the number of inversions. had they been asked the number of inversions, answer would be O(1). please give your approach, and what do you think answer should be? Algorithms algorithms time-complexity + – aambazinga 704 views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply Verma Ashish commented Dec 28, 2018 reply Follow flag i think they ask about number of inversion pairs then we simply get in O(1). $total-r\implies\frac{n(n-1)}{2}-r$ 0 0 replyShare aambazinga commented Dec 28, 2018 reply Follow flag @Verma Ashish please see the doubt i have underlined... they have asked about inversion pairs... not the number of inversion pairs.. i think answer should be O(n logn ) in case of number of inversion pairs, answer would be O(1) 1 1 replyShare Please log in or register to add a comment.