Archived

This topic is now archived and is closed to further replies.

sega_boy

recursive permutations PLZ HELP

Recommended Posts

Hello friends. This is my first post in GAMEDEV and I''m very excited. I have this HW in data-structures, which I have no bloody idea how to solve :> I have to find RECURSEVLY all the permutations (only one iteretive loop can be used in the program, and no additional strings can be used, only one for string input) F(JEDI)={EJDI, DIEJ, EJDI...} Thank''s in advance :>

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by sega_boy
Hello friends.
This is my first post in GAMEDEV and I''m very excited.

I have this HW in data-structures, which I have no bloody idea how to solve :>

I have to find RECURSEVLY all the permutations (only one iteretive loop can be used in the program, and no additional strings can be used, only one for string input)

F(JEDI)={EJDI, DIEJ, EJDI...}

Thank''s in advance :>


Refer to next line for solution
Refer to previous line.

Share this post


Link to post
Share on other sites
Hello, sega_boy.

I''m sorry that your first post here has to turn out this way, but remember that Gamedev is a web site to help game developers in creating games, so I doubt anyone here is willing to help you out with homework questions.

As the FAQ points out, this homework has been given out to you so you can understand and learn the inner workings of what you are studying, and if we were to help you, this would destroy the whole point of having homework to do.

Remember, make a man a fire and he''ll be warm for the rest of the day. Set a man on fire and he''ll be warm for the rest of his life (copyrighted by whoever I took this from, sry).

PS : you counted twice the permutation "EJDI".

Share this post


Link to post
Share on other sites
well, it''s quite simple. You need to find the recursive case, and the terminal case.

recursive case: pick a letter, and add it to the output. Recurse on the set of letters minus that one
Terminal case: we have no more letters to choose from!

Share this post


Link to post
Share on other sites
I found this homework independently on different forum and I already solved it (twice). If you want know the url: http://www.mikrogen.com/cz/phpbb2/viewtopic.php?t=153
I hope it is correct.

PS: This is my first post too.

Share this post


Link to post
Share on other sites