How does Counting Inversions work in the following code?

Revision en1, by -synx-, 2017-02-24 18:52:56
a = 0
while max(V) > 0:
    C = [ 0 ] * max(V)
    for x in V:
        if x%2==0:
            a += C[x//2]
        else:
            C[x//2] += 1
    V = [ x//2 for x in V ]
print(a)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English -synx- 2017-02-24 18:52:56 267 Initial revision (published)