0 votes 0 votes Given an array of n elements, two elements in the array a[i] and a[j] are said to be inverse only if a[i]>a[j] && i<j. What is the time complexity required to find the number of inverses in the given array using merge sort? a) O(n) b) O(n2) c) O(nlogn) d) O(logn) Algorithms algorithms merge-sort time-complexity + – Sambhrant Maurya asked Aug 6, 2018 Sambhrant Maurya 345 views answer comment Share Follow See 1 comment See all 1 1 comment reply Gatetarget_100 commented Aug 6, 2018 reply Follow Share Well Explained here: https://www.geeksforgeeks.org/counting-inversions/ 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Answer is Option B, Largest possible inversions are possible when array is in decreasing order , Eg . [5,4,3,2,1] therefore total pairs formed is nC2 , = n(n-1)/2 =O(n^2) Therefore , TC = O(n^2) Aniket1710 answered Jul 10, 2023 Aniket1710 comment Share Follow See all 0 reply Please log in or register to add a comment.