I just discovered a power-up search algorithm. I searched google after solutions, but did not find any that worked well, so I figured it out myself. But I wonder what algorithm it is, because I can not find it on the network or in any books. I mean, does he have a name? Compared to the algorithms that I found on some sites for calculating power gains, I think mine is much better and wonders why no one is using it?
This is the algorithm:
R <- []
L <- [ e1, e2 ... en ]
c <- 0
function: powerSet(L, c)
R <- R union L
for e in L starting at c
powerSet(L\{e}, c)
end
return R
end
And here it is implemented in Java:
public static void powerSet(List<String> list, int count)
{
result.add(list);
for(int i = count; i < list.size(); i++)
{
List<String> temp = new ArrayList<String>(list);
temp.remove(i);
powerSet(temp, i);
}
}
source
share