how to make factorial

1 次查看(过去 30 天)
Bathrinath
Bathrinath 2013-12-9
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 个评论
Roger Stafford
Roger Stafford 2013-12-9
编辑:Roger Stafford 2013-12-9
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by