how to make factorial
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
hello, let the number of machines 'm' = 3 and number of jobs 'n' = 6.The given sequence is 3-4-2-6-5-1. I need 6! combination of the sequence. Here some conditions are applied. According to 'm' value 'n' can be divided into two parts.
First part values should not be swapped each other with first part values (4-3-2-6-5-1 should not be done)
Where as the first element of the first part can be swapped with the first/second/third element of the second part and second part values can be swapped with the second part (6-4-2-3-5-1, 3-4-2-5-6-1 these can be done)
Like that it continues till all the possibility of elements are swapped.
Here the task is to find the no of possible combinations of interchanging the elements between 2 partitions.
regards, SBN
1 comentario
Roger Stafford
el 9 de Dic. de 2013
Editada: Roger Stafford
el 9 de Dic. de 2013
It is not clear to me what you are asking, Bathrinath. For example, you say that you can do this:
3-4-2-6-5-1 --> 6-4-2-3-5-1
Presumably you can also then do this:
6-4-2-3-5-1 --> 6-3-2-4-5-1
followed by this:
6-3-2-4-5-1 --> 4-3-2-6-5-1
In so doing, you would have performed in three swaps something you stated was not allowed, namely that the 3 and 4 in the first part have in effect been interchanged. Can you explain more clearly what it is you really mean?
I am guessing that what you really mean is that you are dividing up the six positions into two groups, one consisting of the first m positions and the other the remaining 6-m positions. Ordering within each group does not matter. What matters is what numbers lie in each group. These are what is known as 'combinations' and their total number would be
6!/m!/(6-m)!,
not 6!. The matlab function 'nchoosek' can be used to generate a list of all such groupings.
The algorithm you describe involving a sequence of swaps sounds like a very difficult method of achieving what you are seeking, whether it is for combinations or something else. The problem is first, making sure you don't duplicate a grouping you have already had, and second, making sure that all possibilities have been realized. There are much more efficient algorithms than that for this purpose.
Respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!