5
$\begingroup$

First I give an example. For an integer set $(0,1,2,3,4)$, there are eight kinds of subdivision or partition like this $$(0,4);\\~~(0,1)(1,4);~~(0,2)(2,4);~~(0,3)(3,4);\\ (0,1)(1,2)(2,4);~~(0,1)(1,3)(3,4);~~(0,2)(2,3)(3,4);~~\\(0,1)(1,2)(2,3)(3,4); $$

For a more general set $(0,1,2,...,n)$, there are $2^{n-1}$ kinds of partition.I believe that there must be a special name for this kind of partition mathematically. How can I realize it in MMA?

$\endgroup$
8
$\begingroup$

P[n] will return the set you are asking

P[n_] := Partition[Join[{0}, #, {n}], 2, 1] & /@ Subsets[Range[n - 1]]

P[4]   

{{{0, 4}}, {{0, 1}, {1, 4}}, {{0, 2}, {2, 4}}, {{0, 3}, {3, 4}}, {{0, 1}, {1, 2}, {2, 4}}, {{0, 1}, {1, 3}, {3, 4}}, {{0, 2}, {2, 3}, {3, 4}}, {{0, 1}, {1, 2}, {2, 3}, {3, 4}}}

$\endgroup$
  • $\begingroup$ Thanks, it works well!!! $\endgroup$ – Mark_Phys Apr 1 at 9:08
  • $\begingroup$ @user10709 I'm glad I helped! $\endgroup$ – J42161217 Apr 1 at 9:10
  • $\begingroup$ Of course, you can combine the functions so that only one application of Map[] is needed: Partition[Join[{0}, #, {n}], 2, 1] & /@ Subsets[Range[n - 1]]. $\endgroup$ – J. M. will be back soon Apr 1 at 14:35
  • $\begingroup$ @J.M.isslightlypensive yes, you are right $\endgroup$ – J42161217 Apr 1 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.