Began algorithm implementation.
This commit is contained in:
parent
6cfc94869b
commit
7fa5f88499
@ -61,11 +61,25 @@ package Assignments.A2;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates, if possible, two equal subsets of a given set of elements that are equal to each other.
|
||||||
|
*
|
||||||
|
* @author Jonathan Turner
|
||||||
|
* @version Spring 2024
|
||||||
|
*/
|
||||||
public class Partition {
|
public class Partition {
|
||||||
|
|
||||||
private int[] set;
|
private int[] set;
|
||||||
private List<List<Integer>> subsets;
|
private List<List<Integer>> subsets;
|
||||||
|
|
||||||
|
public void performAlgorithm() {
|
||||||
|
|
||||||
|
int totalSum = 0;
|
||||||
|
for (int i = 0; i < this.set.length; i++) {
|
||||||
|
totalSum += this.set[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the list of subsets using Bit Shift Counting by iterating over all combinations of 1 to n.
|
* Generates the list of subsets using Bit Shift Counting by iterating over all combinations of 1 to n.
|
||||||
* After shifting the counter, the current subset is created initialized and if 1 shifted by j is logically
|
* After shifting the counter, the current subset is created initialized and if 1 shifted by j is logically
|
||||||
|
@ -23,7 +23,11 @@ public class FakeCoin extends Application {
|
|||||||
* @postcondition a new FakeCoin application is created.
|
* @postcondition a new FakeCoin application is created.
|
||||||
*/
|
*/
|
||||||
public FakeCoin() {
|
public FakeCoin() {
|
||||||
super(new String[]{"The number of coins","Set FakeCoin Weight and Location","Find Fake Coin"});
|
super(new String[]{
|
||||||
|
"The number of coins",
|
||||||
|
"Set FakeCoin Weight and Location",
|
||||||
|
"Find Fake Coin"
|
||||||
|
});
|
||||||
this.setLocation = false;
|
this.setLocation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user