Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def countInversionsNaive(inputArray)
- array_length = inputArray.length
- x = 0
- y = 1
- count = 0
- while (x < array_length)
- while (y < array_length)
- if inputArray[x] > inputArray[y] and x < y then
- count = count + 1
- end
- y = y + 1
- end
- x = x + 1
- y = x + 1
- end
- return count
- end
Advertisement
Add Comment
Please, Sign In to add comment