Counting power sets

you must create a function powers that takes an array, and returns the number of subsets possible to create from that list. In other words, counts the power sets.

For instance  powers([1,2,3]) => 8  即求 集合的子集

good example:

public class Powers {

  public static BigInteger powers(int[] list){

  return BigInteger.valueOf(2).pow(list.length);

  }

}

public static BigInteger powers(int[] list) {

return BigInteger.ONE.shiftLeft(list.length);

}

 

posted @ 2015-02-07 21:44  刘奇CUMT  阅读(102)  评论(0编辑  收藏  举报