• http://facebook.com/
• https://www.google.com/accounts/o8/id
• https://me.yahoo.com
COST (GBP) 1.04 0.19 0

# Inversion Sequence

Computes the inversion sequence of a permutation.
Controller: CodeCogs  ## Dependents C++

## Inversion Sequence

 std::vectorinversion_sequence( int n int* p )
For a given permutation

the inversion sequence is defined as

with .

This function calculates the inversion sequence of a permutation based on the above formula and returns its value as a C++ vector object.

## Example:

#include <codecogs/maths/combinatorics/permutations/inversion_sequence.h>
#include <iostream>
int main()
{
int sigma = {3, 5, 1, 4, 2};
std::vector<int> result = Maths::Combinatorics::Permutations::inversion_sequence(5, sigma);
std::cout << "The inversion sequence of the Sigma permutation: ";
std::cout << std::endl;
for (int i = 0; i < 5; i++)
std::cout << result[i] << "  ";
std::cout << std::endl;
return 0;
}

## Output:

The inversion sequence of the Sigma permutation:
0  0  2  1  3

## References:

SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html

### Returns

the inversion sequence of the given permutation

### Authors

Lucian Bentea (August 2005)
##### Source Code

Source code is available when you buy a Commercial licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.