info.mrupp.isoak1
Class Permutations

java.lang.Object
  extended by info.mrupp.isoak1.Permutations

public class Permutations
extends java.lang.Object

Permutation related functions. Provides static methods for the computation of all permutations of a given size, all prefixes of given length of permutations of a given size, etc.


Constructor Summary
Permutations()
          All functionality is provided via static methods, so there is no need to construct objects of this type.
 
Method Summary
static int[][] permutations(int n)
          All permutations of {0,1,...,n-1}.
static int[][] prefixes(int k, int n)
          All prefixes of given length of all permutations of given length.
static int[][] prefixesPrecomputed(int k, int n)
          Precomputed prefixes of given length of permutations of given length.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Permutations

public Permutations()
All functionality is provided via static methods, so there is no need to construct objects of this type.

Method Detail

permutations

public static int[][] permutations(int n)
All permutations of {0,1,...,n-1}. Uses Heaps method.

Parameters:
n - permutation size.
Returns:
all permutations of {0,1,..,n-1} as an array of arrays.

prefixes

public static int[][] prefixes(int k,
                               int n)
All prefixes of given length of all permutations of given length. Generates all length k prefixes of all permutations of {0,1,...,n-1} in lexicographic order. - If k == 0, an empty matrix is returned. - Once calculated, permutation prefixes are kept across function calls. - There are (n over k)k! = n!/(n-k)! prefixes of length k of permutations of n elements.

Parameters:
k - prefix length.
n - permutation size.
Returns:
all permutations of {0,1,..,n-1} as an array of arrays.

prefixesPrecomputed

public static int[][] prefixesPrecomputed(int k,
                                          int n)
Precomputed prefixes of given length of permutations of given length. Generates all length k prefixes of all permutations of {0,1,...,n-1} in lexicographic order. Currently, 0 <= n <= 6. - If k == 0, an empty matrix is returned. - Once calculated, permutation prefixes are kept across function calls. - There are (n over k)k! = n!/(n-k)! prefixes of length k of permutations of n elements.

Parameters:
k - prefix length.
n - permutation size.
Returns:
all permutations of {0,1,..,n-1} as an array of arrays.