Time Complexity for binary permutation representation of n bits
问题 I have return a below code in java to produce the possible binary representation of n digits. public List<String> binaryRepresenation(int n){ List<String> list = new ArrayList<>(); if(n>0){ permuation(n, list, ""); } return list; } private void permuation(int n, List<String> list, String str){ if(n==0){ list.add(str); }else{ permuation(n-1, list, str+"0"); permuation(n-1, list, str+"1"); } } For n=3, it produces 001 001 010 011 100 101 110 111 combinations. Overall this function produces 2^n