All subsets of a given set
Now using our recursive solution we will try to get all the subsets of a given set.
In following program Arrset is given set of integers and the program will print all the subsets. Each subset is shown using curly braces and commas separating elements{}. The function check is not needed in this case. The value of choice is two because for each element in the set we just have to check whether the element should be included in that particular subset or not. And finally the function print changes. Print will now check the value of element i and will print it as a part of subset or ignore it.
Instead of writing the program here, this time I have posted the program on Rapidshare, and giving the link.
http://rapidshare.com/files/151374580/rec_substring.cpp.html
The above program will produce the following output.
{} {8 } {7 } {7 8 } {6 } {6 8 } {6 7 } {6 7 8 }
{5 } {5 8 } {5 7 } {5 7 8 } {5 6 } {5 6 8 } {5 6 7 }
{5 6 7 8 }
Number of solutions 16
In following program Arrset is given set of integers and the program will print all the subsets. Each subset is shown using curly braces and commas separating elements{
Instead of writing the program here, this time I have posted the program on Rapidshare, and giving the link.
http://rapidshare.com/files/151374580/rec_substring.cpp.html
The above program will produce the following output.
{} {8 } {7 } {7 8 } {6 } {6 8 } {6 7 } {6 7 8 }
{5 } {5 8 } {5 7 } {5 7 8 } {5 6 } {5 6 8 } {5 6 7 }
{5 6 7 8 }
Number of solutions 16
1 Comments:
great work Video Player
By Rahul, at 12:25 AM
Post a Comment
<< Home