n is the number of the original list, which we divided by 2. So we have 2 lists. we sort each list recursively by merge sort and the size of each is n/2. Now we compare each member of list A by list B for merge and counting inversions. if ai is smaller than bi then we don't have an inversion but if it is greater then we should swap and we have an inversion. for example, imagine a3(which is ai) is greater than b4, so it means a3,a4,..,an/2 are greater than b4. so the number of inversions(which is related to a3) is (n/2)-3 because until i (which is3), we didn't have any inversion(or we counted before).
Thanks, helped me visualize how this algorithm works!
Welcome. Please have a look at my other videos too
Thanks, would you do tree traversals, matrix computations, gausian eliminations Using parallel programming approach?
Twahir Abasi appreciate your suggestions .. will try to do in future.
Too much jerks are causing headache
may I know why it is n/2-i ,why it isn't just plus 1?
it's not just a single pair
n is the number of the original list, which we divided by 2. So we have 2 lists. we sort each list recursively by merge sort and the size of each is n/2. Now we compare each member of list A by list B for merge and counting inversions. if ai is smaller than bi then we don't have an inversion but if it is greater then we should swap and we have an inversion. for example, imagine a3(which is ai) is greater than b4, so it means a3,a4,..,an/2 are greater than b4. so the number of inversions(which is related to a3) is (n/2)-3 because until i (which is3), we didn't have any inversion(or we counted before).