Google Answers Logo
View Question
 
Q: algorithms ( Answered,   0 Comments )
Question  
Subject: algorithms
Category: Computers > Algorithms
Asked by: cyang98-ga
List Price: $2.00
Posted: 03 Dec 2002 07:58 PST
Expires: 02 Jan 2003 07:58 PST
Question ID: 118432
A recusive algorithm or sample C or C++ or java program code that can
print out all the possible combination order of a character string.
For ex: give "ATM", will print out:
"ATM", "TAM", "TMA", "MAT", "MTA", "AMT". (n! number orders, n is the
nubmer of characters in the string).
Answer  
Subject: Re: algorithms
Answered By: xargon-ga on 03 Dec 2002 08:20 PST
 
I have two such algorithms for you, both written in C.  They both do
what you need, although you can easily modify them if need be.  Code
is from SourceForge.net and is under the GNU General Public License.


Permutation Generator
This one works, but there could definately be some cleanup done to the
code.  It is commented a little, but easy to follow.
http://sourceforge.net/snippet/detail.php?type=snippet&id=100209

String Permutation Generator
This is a more elegant recursive function, with fewer lines of code
than the one above.  The comments allow for ease of use and
modification, although I see no real reason to need to modify this
snippet.
http://sourceforge.net/snippet/detail.php?type=snippet&id=100376


I hope that helps with your problem!
Xargon-ga
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy