Algorithm for permutations

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:

Code :

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?

Re: Algorithm for permutations

I'm a bit lost in the math jargon and don't want to study up on it. Can you put the assignment into plain English?

Re: Algorithm for permutations

I got it pretty soon afterwards. Thanks anyways.