Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. 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:

```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?

2. 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?

3. Re: Algorithm for permutations

I got it pretty soon afterwards. Thanks anyways.