#include
#include
using namespace std;
vector final;
int a=0;
void printsubsequences(string s,string ans,int i,int n){
if(i==n){
final.push_back(ans);
return; }
printsubsequences(s,ans,i+1,n);
printsubsequences(s,ans+s[i],i+1,n);
}
void bubblesort(vectorfinal){
int size=final.size()-1;
for (int i = 0; i < size; ++i) {
for (int j = 0; j < size - i; ++j) {
if (final[j] > final[j + 1]) {
string temp = final[j];
final[j] = final[j + 1];
final[j + 1] = temp;
}
}
}
for(int i=0;i<=size;i++){
cout<<final[i]<<endl;
}
}
int main(){
string s=“ab”;
int n=s.length();
printsubsequences(s,"",0,n);
bubblesort(final);
return 0;
}