i have to make a program to make all possible combination through brute force approach...
the question is that if suppose i have 3 tasks and 2 processes....i will make a 3x2 array and make all possible combinations to assign every task to every process and thus make different combinations..note that i don't have to create process through fork() or stuff like that...i simply want to show all possible combinations of how 3 tasks can be assigned to 2 process..i have to show every combination..a combination will be,which have all tasks completed through processe(s).i will show u some example of how to create combinations...
e.g-1
P1 P2
------
T1 T2
T3 -
- -
e.g-2
P1 P2
------
T1 T2
- T3
- -
e.g-3
P1 P2
------
T1 -
T2 -
T3 -
e.g-4
P1 P2
------
T2 -
T1 -
T3 -
hence every possible factor...u can see that an e.g have all tasks..i.e.T1,T2,T3
and no one is repeated...
kindly help me to make a c++ program to conquer this problem...
Assuming a general case of M processes and N tasks, first generate all N! permutations of the list of tasks (see http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order or just use functions in algorithm), then for each permutation consider all ways you could divide that list for processes. The permutations will take care of order. Just generate all sets of M non negative numbers that add up to N and assign the corresponding sub-sequence to a process.