


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Lecture # 10
void RecPermute(string soFar, string rest) { if (rest == "") { cout << soFar << endl; } else { for (int i = 0; i < rest.length(); i++) { string next = soFar + rest[i]; string remaining = rest.substr(0, i)
P("ac","bd") Permute("", "abcd") P("b","acd") P("c","abd") P("d","abc") P("abc","d") P("abcd","") P("a","bcd") P("ab","cd") P("abd","c") P("abdc","") P("ad","bc") P("acb","d") P("acbd","") P("acd","b") P("acdb","")
void RecSubsets(string soFar, string rest) { if (rest == "") cout << soFar << endl; else { // add to subset, remove from rest, recur RecSubsets(soFar + rest[0], rest.substr(1)); // don't add to subset, remove from rest,recur RecSubsets(soFar, rest.substr(1)); } } void ListSubsets(string str) { RecSubsets("", str); }
bool Solve(Grid