Dynamic programming

hi...
i was given a task of making all possible combinations of a 2d array through brute force algorithm and then find the best from all of them through its cost....
For e.g. if the array is of size 4 X 3...and it have contents lets say....

1 2 3
4 5 6
7 8 9
10 11 12

then one of possible combination can be

1
4
7
10

similarly

1
4
7
11
...

1
4
7
12
...

1
4
8
10
...

1
4
8
11...

and so on... hence all such combinations...remember the above mentioned combinations were stored in a 2d array....and " - " was inserted where there eas no number...for e.g

1 - -
4 - -
7 - -
10 - -

but as itz a 2d array so u cant store ' - ' in it...so it will only be displayed like it....now there will be a randomly generated cost to every combination....as in brute force...first i find all combinations and then select best combination of it....it took lot of time...for e.g.if my array is of 10 X 5

then i have to make 5 power 10 combinations ...which was a huge amount and time consuming...i actually want someone to help me making alternative of it through dynamic programing...thanks....array can be of size n x m...where m can be os size 2 or 3 maximum and n can be of maximum 1000....thanks in advance
i have implemented the brute force approach..but plz help me in making the dynamic programing algorithm for it....
Topic archived. No new replies allowed.