public static void generatePowerSet(ArrayList<Pair<Integer,Integer>> pairList, int n_items) {
Deque<Integer> set = new ArrayDeque<>();
if (n_items == 0) {
System.out.println(set);
return;
}
Object[] pair_array = pairList.toArray();
// consider the n'th element
set.addLast((Integer) pair_array[n_items - 1]);
generatePowerSet(pairList, n_items - 1);
// or don't consider the n'th element
set.removeLast();
generatePowerSet(pairList, n_items - 1);
System.out.println(set);
}
I'm having trouble finding documentation that will allow me to do this, so far I have this function to generate a powerset with inputs (pairList, int n_items)
n_items is the number of pairs in the ArrayList I tried to change the array list to an array (toArray()) but am having type conversion issues while passing in the arrayList. Is there a better way I can make a power set from this arraylist?