当然,17 世纪的敲钟人都知道这一点。那么,对于一些组合历史来说怎么样?
See Steinhaus Johnson Trotter 算法 http://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm或咨询您当地的变铃小组。
我对你问题的第二部分做了一些研究,即是否可以使用重复的元素来做到这一点。我相信答案是“是的,但并不那么容易”。此外,不可能通过仅相邻交换来排列具有重复元素的列表,这一点可以很容易地从集合中看出{0, 0, 1, 1}
。然而,只需单次交换就可以实现。
The basic approach is to use the basic change-ringing algorithm, but on groups of identical elements instead of on single elements. For a group of k
identical elements, you need to be able an algorithm for combinations of the list 0n-k1k (where n is the total size of the base set). A number of such algorithms exist, but I can't find any which are really simple; the simplest one is (roughly speaking) to assign a direction to the overall group, and also a direction to each 1
(in a similar fashion to the Shimon Even algorithm). When moving the group left, the leftmost element sweeps back and forth; every time it changes direction, the next mobile element to the right steps one; etc. This eventually moves the entire group from the right-hand side of the list to the left-hand side, after which its overall direction is flipped and it proceeds back to the original configuration, now with the rightmost element leading the sweeps.
由于在这种情况下方向反转的数量可能是偶数,因此上述算法可能无法追踪出排列循环,但我相信可以使用更复杂的算法产生循环。实际上,您正在图中寻找由每个排列(排列面体的变体)中可能的单个交换引起的哈密尔顿循环,但是,虽然哈密尔顿循环确实存在,但它们并不那么容易找到,因为这些图是相当大。