title: Parallel algorithm to produce all possible sequences of a set
body: <p>I'm having difficult time while trying to produce all possible strings of a given character set. Let <code>S</code> be set of symbols. I need to process all possible combinations of <code>S</code> in length <code>n</code>. For example if <code>S={'a','b','+','-'}</code> and <code>n=4</code> the algorithm should process following sequences:</p>
  
  <pre><code>aaaa
  aaab
  abab
  +aa-
  // And all other sequences in the universe
  </code></pre>
  
  <p>Currently my algorithm is a non-efficient recursive algorithm described below. I have two question:</p>
  
  <ol>
  <li>Is there a faster algorithm?</li>
  <li>Is there a parallel algorithm to solve this problem?</li>
  </ol>
  
  <p>Current implementation: (Simplified)</p>
  
  <pre><code>void workhorse(vector&lt;char&gt; &amp;input, vector&lt;char&gt;::iterator i)
  {
      if(i==inputs.end()) {
          // process the input
          return;
      }
      else {
          for( const auto&amp; symbol : S) {
              *i=symbol;
              workhorse(input, i+1);
          }
      }
  }   
  </code></pre>