Learn R Programming

Tex4exams (version 0.1.2)

inversions: Count the number of total inversions of a permutation

Description

inversions() counts the number of inversions of a permutation.

Usage

inversions(x)

Value

The total number of inversions in a list.

Arguments

x

a permutation of 1, 2, ..., n.

Details

Input must be a list of numbers.

See Also

inversionv

Examples

Run this code
inversions(c(3,1,2))


Run the code above in your browser using DataLab