MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / kth_perm

Function kth_perm

Number Theory/Factoradic Number System.cpp:40–42  ·  view source on GitHub ↗

returns the k-th lexicographically smallest permutation of size n 0-th permutation is the unit permutation i.e. 0, 1, 2, .... n-1

Source from the content-addressed store, hash-verified

38// returns the k-th lexicographically smallest permutation of size n
39// 0-th permutation is the unit permutation i.e. 0, 1, 2, .... n-1
40vector<int> kth_perm(int n, int k) { // k < n!
41 return get_perm(n, decimal_to_factoradic(k));
42}
43vector<int> factoradic_order(vector<int> p) {
44 o_set<int> se;
45 int n = p.size();

Callers

nothing calls this directly

Calls 2

get_permFunction · 0.85
decimal_to_factoradicFunction · 0.85

Tested by

no test coverage detected