title: Finding by Recursion Sequences of Characters in a Char Array
body: <p>I have a recursion project to find all the sequences(or subsets) of a Char array as such that each character appears in the same order.  For Example, for the array Char[] letters = <code>{'A', 'B','C','D'}</code>
  <br>The one letter sequences are "A","B","C,"D". 
  <Br>Two letter sequences are "AB","AC","AD","BC","BD","CD".
  <br>Three letter sequences are "ABC", "ABD","ACD","BCD"
  <br>Four letter sequence is "ABCD"</p>
  
  <p>Now I thought I was on the right track with the code below, but I'm getting a lot of duplicates. I'm getting really frustrated. If anyone can point me in the right direction, I would appreciate it.</p>
  
  <pre><code>// print all subsets of the characters in s
      public static void combinations(char[] array) { combinations("", array, 0); }
  
      // print all subsets of the remaining elements, with given prefix 
      private static void combinations(String prefix, char[] array, int index) {
  
          for(int i = index; i &lt; array.length; i++)
          {
  
              System.out.println(prefix + array[i]);
          }
  
  
              if (index &lt; array.length) { 
                  for(int i = index; i &lt; array.length; i++){
                      combinations(prefix + array[i], array, index+1);
                  }
              }
  
      }
  </code></pre>
  
  <p>Editting out my edit for clarification.</p>