Answer the following questions In class we discussed a recur
Solution
import Java.io.IOExecption //header files
Class code
{
// Code for printing of the subsets
static void printSubsets(int set[])
{
int n=T[].length; // inserting set length into n variable
//Here the loop will run for 2^n times
//(1<<n) is a number with j the bit so when we and them with the subset number we get the number of subsets in given
System.out.println(\"subsets are\");
for(int I=0;I<(1<<n);I++)
{
System.out.print(\"{\");
//Loop will print the current subset
for(j=0;j<n;j++,)
{
if((I&(1<j)>0)
System.out.print(set[j]+\"\");
System.out.println(\"}\");
}
}
//Programs execution starts from here
Public static void main(String args[])
int T[]={2,4,7,9};. // given superset
printSubsets(T[]); //calling the function to print subsets
}
}
output:
subsets are
{}
{2}
{4}
{7}
{9}
{2 4}
{2 7}
{2 9}
{4 7}
{4 9}
{2 4 7}
{2 7 9}
{4 7 9}

