How can I maximally partition a set?

后端 未结 6 1254
既然无缘
既然无缘 2021-01-03 14:17

I\'m trying to solve one of the Project Euler problems. As a consequence, I need an algorithm that will help me find all possible partitions of a set, in any order.

6条回答
  •  天命终不由人
    2021-01-03 15:00

    In general I would look at the structure of the recursion used to compute the number of configurations, and build a similar recursion for enumerating them. Best is to compute a one-to-one mapping between integers and configurations. This works well for permutations, combinations, etc. and ensures that each configuration is enumerated only once.

    Now even the recursion for the number of partitions of some identical items is rather complicated.

    For partitions of multisets the counting amounts to solving the generalization of Project Euler problem 181 to arbitrary multisets.

提交回复
热议问题