Question
Modify the java code described in the class for computing all possible subsets of a given set, {1,2,3,4,5} public class Powerset { public static void
Modify the java code described in the class for computing all possible subsets of a given set, {1,2,3,4,5}
public class Powerset { public static void main(String[] args) { int[] set = { 1, 2, 3, 4, 5 }; int n = 7; int temp; System.out.print("The set contains: "); for (int s : set) System.out.print(s + " ");
System.out.println(); System.out.println("The power set contains: "); int i = 0; while (1 < Math.pow(2, n)) {
temp = i; System.out.print("Set " + (i + 1) + ": "); for (int j = 0; j < n; j++) { if (temp % 2 == 1) System.out.print(set[j] + " "); temp = temp / 2; } System.out.println(); i++; } } }
So that it will only print the X-th subset, where X is the last digit of youre A number.
Write the last digit of your A number:7
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started