Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions