Re: [algogeeks] Non-redundant permutations of the string

2011-07-20 Thread kavitha nk
pls explain...i cant get the idea...:(

-- 
//BE COOL//   kavi

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Non-redundant permutations of the string

2011-07-20 Thread Anantha Krishnan
@SkRiPt KiDdIe

I got your logic.
Nice.
Thanks.

Regards
Anantha Krishnan

On Wed, Jul 20, 2011 at 2:04 PM, SkRiPt KiDdIe wrote:

> While you are on a state do not change ur state on encountering a specific
> character if u have already done so earlier.This check in addition to the
> usual permutation generation code gives the desired output.
>
> Above code works only for lowercase characters.Bits of mask are used to
> remember previous visit.
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Non-redundant permutations of the string

2011-07-20 Thread SkRiPt KiDdIe
While you are on a state do not change ur state on encountering a specific
character if u have already done so earlier.This check in addition to the
usual permutation generation code gives the desired output.

Above code works only for lowercase characters.Bits of mask are used to
remember previous visit.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Non-redundant permutations of the string

2011-07-20 Thread ~*~VICKY~*~
@SkRiPt KiDdIe

kindly explain the working of ur algo with the given example

On Wed, Jul 20, 2011 at 1:09 AM, SkRiPt KiDdIe wrote:

> #include
> #include
> using namespace std;
>
> void permute(string str,int x,string print)
> {
>
> int mask=0;
>
> if(!x){cout<
> for(int i=0;i {
> if(mask&(1<<(str[i]-'a')))continue;
> if(i && i+1 permute(str.substr(0,i)+str.substr(i+1,x-i),x-1,print+str[i]);
> else if(i)
> permute(str.substr(0,i),x-1,print+str[i]);
> else
> permute(str.substr(1,x-1),x-1,print+str[i]);
> mask=mask^(1<<(str[i]-'a'));
> }
> }
>
> int main()
> {
> string str,print="";
> cin>>str;
> permute(str,str.size(),print);
> return 0;
>
> }
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Cheers,

  Vicky

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Non-redundant permutations of the string

2011-07-19 Thread SkRiPt KiDdIe
#include
#include
using namespace std;

void permute(string str,int x,string print)
{

int mask=0;

if(!x){cout<>str;
permute(str,str.size(),print);
return 0;
}

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Non-redundant permutations of the string

2011-07-19 Thread Anantha Krishnan
Can somebody please help me to  print all non-redundant permutations of the
string. For ex. If string is "abab" the permutations are {baab, abba, abab,
baba, bbaa, aabb}

Thanks & Regards
Anantha Krishnan

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.