
EXPERT ANSWER
Implementation in C++
#include <bits/stdc++.h>
using namespace std;
void permute(const string &str, int low, int high );
void permute(const string &str);
int main()
{
string str;
cout<<“Enter Input String:: “;
cin>>str;//To Read input String
permute(str);
return 0;
}
void permute(const string &str, int low, int high )
{
if (low== high)
cout<<str<<endl;
else
{
for (int i = low; i <= high ; i++)
{
string temp=str;
swap(temp[low], temp[i]);
permute(temp, low+1, high);
swap(temp[low], temp[i]);
}
}
}
void permute(const string &str){
int n = str.size();
permute(str, 0, n-1);
}
