Algorithm to connect every node between each level of a graph / tree

24 Views Asked by At

I have a problem where I need to be able to find the unique combinations of data spread across n arrays. Each array can contain around 2 to 15 values. In essence I think what I'm looking for is the unique paths through this data. My mind jumps to this being some kind of tree or graph problem. I could do trees and write a recursive algorithm to do a BFS. I'm no algorithm expert though, any suggestions how I can accomplish this?

Ex 1.

arr1 = 0     6     3    10
arr2 = 75    10
arr3 = 99    50 
arr4 = 10

The resulting new list of numbers I'd hope to generate by walking down the tree:

0 75 99 10
0 75 50 10
0 10 99 10
0 10 50 10


               0

        75           10

    99    50      99    50

10         10   10         10


Ex 2.

arr1 = 0     6     3    10
arr2 = 75    10
arr3 = 99    50 
arr4 = 10    30    60   50


The resulting new list of numbers I'd hope to generate by walking down the tree:

0 75 99 10 60
0 75 50 10 60 
0 10 99 10 60
0 10 50 10 60
0 10 50 10 50...

               0

        75           10

     99    50      99    50

10   30   60  50  10   30   60   50
0

There are 0 best solutions below