HI all
Can anyone help me with this algorithm (I ned to write the code in java)......The java code would also be helpful

Describe a recursive algorithm for enumerating all permutations of the numbers {1,2,...,n}.

I'd appriciate it if somebody could explain this problem to me and give me some idea on how i can get started

Many Thanks

Recommended Answers

All 3 Replies

Have you understood the question yourself ? What do you mean by this:

Describe a recursive algorithm for enumerating all permutations of the numbers {1,2,...,n}

I don't think so, with the way you have copy-pasted the assignment-looking statement. If you haven't understood the question in the first place you cannot even begin with thinking how to answer it. So if you understand that, you yourself would gain a slight insight into what should be done to solve it.

Thanks a lot!
If i didn't know anything 'bout the question, i wouldn't have had posted it!

I know htat for n elements, there are n! possible permutations
And I think that the procedure should be something like this:
(to make it recursive) enumerate the permutatipons of n-1 in each
time that the recursive algorithm is called

It doesn't matter if you or no one else doesn't share any ideas
I've always come up with solutions of my own

oh...and for the copy-paste thing...I just wanted to make sure I state my problem clearly
thanks anyway

Firstly, there's no need to be so heated up for nothing you can save your energies for your solution finding activity. I wasn't trying to be rude or mean even. All I wanted to make sure was that you understand the problem well, which I did not think you had. Since your understanding of the problem is very important for your answer to be in the right direction otherwise you cannot expect that to happen.

And to answer some of your questions:
>If i didn't know anything 'bout the question, i wouldn't have had posted it!
You don't know thats the reason you have posted the question and posted
how you'd go about solving it. Don't try to show-off now that you knew so much.

And if you know so much :
>I know htat for n elements, there are n! possible permutations
>And I think that the procedure should be something like this:
>(to make it recursive) enumerate the permutatipons of n-1 in each
>time that the recursive algorithm is calle

Then why haven't you already started working on it with whatever you know of it ? Where's the code to show us your effort. All this knowledge yet no code to post means, quite straightforwardly, no effort put in till yet.

>It doesn't matter if you or no one else doesn't share any ideas
>I've always come up with solutions of my own

Hmm... Why would somebody like you then start a thread asking for help and solutions of others, in the first place.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.