Skip to content

theSaSo/CountInversions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

CountInversions

Takes an integer slice, returns the slice sorted and the number of inversions in the slice. An inversion is defined as all instances of slice[i] > slice[j] while i < j. The number of inversions is a measure of how unsorted the slice is, hence useful for e.g. finding numberical similarity between two ranked lists. The higher the count, the more unsorted the slice. To work with arrays, simply supplement fixed sizes in the definitions of slices.

Sample Input

slice = [1, 88, 54, 32, 16, 2, 9]

Sample Output

[1 2 9 16 32 54 88], 14

About

Takes an integer array, returns the array sorted and the number of inversions in the array.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages