誰かがnビット文字列(すべての可能な組み合わせ)を生成する方法を教えてもらえますか?つまり、分割統治法を使用して0から2^n-1までのビットを数えます。
次のアルゴリズムでこれを行うことができましたが、空間の複雑さと時間の複雑さはO(2 ^ n)です。誰かが私に(分割統治法を使用して)これよりも少ないスペースを必要とするより良いアルゴリズムを教えてもらえますか?
ArrayList generate(int n)
 {
      if(n==1) 
         {  
            Create an arrayList and store strings "0" and "1";
         }
     else
    {
         generate(n-1)
         now recompose the solution to get 2^n strings and return this arraylist
         "PROBLEM here is that the length of the array list is also getting
         exponential"
    }
 }