0

I am currently trying to write a program to compute permutations of the array [0,1,2,3,4,5], I need to save all the permutations to another array and I also need the first digit, 0, to be fixed.


I have searched through quite a bit of literature on doing this, however I can't seem to be able to do it. any help is greatly appreciated. thank you in advance

4
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by Salem
0

So what do you need help with?

Improving your C++ knowledge to help you write the code?
Improving your google knowledge to help you find the answers with minimal effort?

0

You could use the next_permutation() function present in the stl for generating permutations. You search to get more info about this

1

Then he/she would learn nothing more than how to use iterators.

Votes + Comments
That might actually be an improvement ;)
0

I would like to improve my c++ skills so that I could write the code.


also I have looked into using next_permutation() and i could use that but I would rather like to know how to code it manually.

0

Consider this

permute("abc")
can be broken down into

a + all results of permute("bc");
b + permute("ac");
c + permute("ab");

When you get down to permute("a"), then you stop breaking the problem down, because the answer is trivial at that point.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.