I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.90
sub units 0.00
+
0

unrank combination

viewed 2938 times and licensed 67 times
Generates the combination of \e n objects out of \e m, of the given rank
Controller: CodeCogs

get GPL add to cart

Interface

C++

Unrank Combination

 
std::vector<int>unrank_combinationintm
intn
intrank )
This function generates the combination of n objects out of m, of the given order. The combinations are considered to be ordered lexicographically, as in the following diagram

where the rank of the last combination is

References:

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

Example 1

#include <codecogs/maths/combinatorics/combinations/unrank_combination.h>
#include <iostream>
int main() 
{
  std::vector<int> comb = Maths::Combinatorics::Combinations::unrank_combination(6, 3, 10);
  std::cout << "Size of the combination: " << comb.size() << std::endl;
  for (int i = 0; i < comb.size(); i++)
    std::cout << comb[i] << "  ";
  std::cout << std::endl;
  return 0;
}
Output:
Size of the combination: 3
1  5  6

Returns

the combination with the given index

Authors

Lucian Bentea (August 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

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