![]() |
|
#1
|
|||
|
|||
String Combination AlgorithmWhat is the algorithm to display al possible combinations of a string?
There are N^N combinations If the string is "ab" the output should be: ab,ba,aa,bb 2^2=4 combinations if the string is "abc" the output should be: abc, acb, aab,aac,aaa,aba, ..... 3^3=27 combinations |
|
#2
|
||||
|
||||
|
well I can give some tips, not the full code..
this is example for str with 2 char, CPP / C++ / C Code:
for more than 2 char, 3 or 4 may need 3 or 4 for loops, so obviously you need to use recursion tecniques for this, just try out for two chr first, then implement using recursion... __________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds Last edited by LuciWiz : 26-Mar-2006 at 08:48.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#3
|
|||
|
|||
|
Thanks,
but I know, obviously, how to use loops for finite number of chars. I need to know how to recurs it. |
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Read a .html file, check that file for links | salemite | C Programming Language | 10 | 17-Jan-2008 08:56 |
| Re: Conversion: Binary, Decimal, Hexadecimal | WaltP | C Programming Language | 1 | 10-May-2006 07:49 |
| C++ string from file | small_ticket | C++ Forum | 3 | 05-Jan-2005 08:29 |
| Including Maps and strings?? | maddie | C++ Forum | 17 | 05-Jul-2004 07:25 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The