Can anyone give me some hint regarding this ques
Thanks in advance…
Can anyone give me some hint regarding this ques
Thanks in advance…
You have to find the total no. of pairs (i,j) such that a[i] > a[j] and i < j. This pair is called an inversion. There are many ways to find inversions you can read about them online. Most common ways are using BIT and mergesort.
@shuvam07: This question is nothing but to count number of inversions in a given array. You can implement it using divide and conquer approach. That is let me try it to explain by taking an example
I hope you understand this logic. In addition to this I am attaching my
[1] for further clarity with comments where ever needed. If this is useful don't forget to accept and upvote my answer. still if you have any doubts try to google it as **count number of inversions in given array using divide and conquer method** and open link in geeksforgeeks because it provides with a solved example :)
[1]: https://ideone.com/gneGxE