[algogeeks] Re: All possible permutations of a given string

2011-12-28 Thread ravu sairam
In the link you have specified they are talking about using the C++ STL . I would like to know how is that STL implemented -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

[algogeeks] Re: All possible permutations of a given string

2011-12-28 Thread ravu sairam
What are the parameters it is taking i and j? What are those? We only have to permute(s)-where s is the string. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe

[algogeeks] Re: All possible permutations of a given string

2011-12-28 Thread Gene
Don't forget repeats. The string aaa has only one permutation. A related interesting question is how to write a permutation iterator. Here is the interface: typedef struct { // your code here } PERMUTATION_ITERATOR; /* Initialize the given permutation iterator with the string of n

[algogeeks] Re: All possible permutations of a given string

2011-12-28 Thread Lucifer
@ravu I have mentioned how next permutation works.. Also i have given an example in another post. Please go thru the link.. On Dec 28, 10:47 pm, Gene gene.ress...@gmail.com wrote: Don't forget repeats.  The string aaa has only one permutation. A related interesting question is how to write a

[algogeeks] Re: All possible permutations of a given string

2011-12-27 Thread SAMMM
Have a look at this algo :- Steinhaus–Johnson–Trotter algorithm . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] Re: All possible permutations of a given string

2011-12-27 Thread Lucifer
This might help.. http://groups.google.com/group/algogeeks/browse_thread/thread/d3dafdcd53f101a9# On Dec 28, 11:53 am, SAMMM somnath.nit...@gmail.com wrote: Have a look at this algo :-  Steinhaus–Johnson–Trotter algorithm . -- You received this message because you are subscribed to the Google

Re: [algogeeks] Re: All possible permutations of a given string

2011-12-27 Thread Karthikeyan V.B
Hi, Using Backtracking, void swap(char* x,char* y) { char temp; temp=*x; *x=*y; *y=temp; } void permute(char* a,int i,int n) { int j; if(i==n) printf(%s\n,a); else { for(j=i;j=n;j++) { swap((a+i),(a+j)); permute(a,i+1,n); swap((a+i),(a+j)); } } } But this takes O(n*n!) time -- You received