@SkRiPt KiDdIe

kindly explain the working of ur algo with the given example

On Wed, Jul 20, 2011 at 1:09 AM, SkRiPt KiDdIe <anuragmsi...@gmail.com>wrote:

> #include<iostream>
> #include<string>
> using namespace std;
>
> void permute(string str,int x,string print)
> {
>
>     int mask=0;
>
>     if(!x){cout<<print<<endl;return;}
>
>     for(int i=0;i<x;i++)
>     {
>         if(mask&(1<<(str[i]-'a')))continue;
>         if(i && i+1<x)
>             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.

Reply via email to