Consider the problem of generating all permutations of length k of a set of cardinality n, where n is a non-negative integer number and k < (or) = n is a non negative integer number.
So far, I have the method:
methodB (int[] a) { if |a| = 1 return {a} else sol = { } for every x in a { sub = a – {x} block = method (sub) for each element in block, insert x in front of it } sol = sol U block }
But I know this doesn't really solve the problem, as I need to make it for a predefined space of K. Anyone able to help me out?