Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jan 19th, 2008, 10:42 AM   #11
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Recursive permutation of string

So if you wanted to use the more 'standard' permute algorithm, as is the one I posted, but need the signature to be: void permute(char[] str, int low, int high). You will notice the address of "r" is not changing each recursion. All you need to do is make r a global variable or accessable by the class. That leaves you with the same format for the prototype: void permutate(char *s, int k, int n).

If your algorithm works, it may be more obfucated (or difficult to prove its correctness), but it's certainly more clever. I've never seen a permutation done by swapping characters repeatedly. Where did you get the idea from?
Sane is offline   Reply With Quote
 

Bookmarks