Inversion Sequence
Computes the inversion sequence of a permutation.
Controller: CodeCogs
Dependents
Interface
C++
Inversion Sequence
std::vector<int>inversion_sequence( | int | n | |
int* | p | ) |
Example:
#include <codecogs/maths/combinatorics/permutations/inversion_sequence.h> #include <iostream> int main() { int sigma[5] = {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.htmlReturns
- 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.