C++ recursive string subset? NEED HELP

hi.

/*Write a recursive function that returns a vector of strings
containing all subsets of a string value passed in
(the passed string represents a set of characters just like a vector of char's).
Write a test harness to test your function.

vector<string> generate_subsets(string s)

For example, the subsets of the string value "abc", which represents the set {a,b,c} , are: "abc", "ab", "ac", "a", "bc", "b", "c", and " ".

I made 2 iterative helper functions:
*/
//appends c at the beginning of every element of V and returns the new vector.
//e.g., if V = {"take","give"} and c = "s", it should create V1 = {"stake","sgive"} and return it.
Last edited on
I can't see where you generate the subsets.
i don't know how to create these subsets.
please tell me, help me to do this program.

i want to learn this
Have you tried doing with pen/paper first? If not, give it a go with the "abc" example. You're looking for a repeatable pattern that you can apply to any sequence of distinct characters.
Topic archived. No new replies allowed.