Algorithm all possible combination multiple values
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Algorithm all possible combination multiple values

  1. #1
    Join Date
    Jan 2009
    Posts
    2

    Question Algorithm all possible combination multiple values

    Hello,

    I am looking for an algorithm for generating all possible combinations of an array which has multiple possible values at every index. Example:

    array = [[0,1,2],[0,1],[0,1,2,3],[0,1]]

    So the order of the original array values should be preserved, I only need the possible different combinations of the inner arrays (i.e. the possible values). I have a solution, but it's rather complicated and consists of several loops. So, I would like to know if there is a better way to do this. Some pseudo code would be appreciated. Thanks!

    rookiepr

  2. #2
    Join Date
    Jan 2009
    Posts
    2

    Re: Algorithm all possible combination multiple values

    Never mind, I have solved it myself. The solution is to use an recursive algorithm that takes an multidim array as an argument as well as the row count.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center