public static ArrayList<ArrayList<Integer>> Partition(int val, int start, int size) {
ArrayList<ArrayList<Integer>> r = new ArrayList<ArrayList<Integer>>(); if (start * size > val) { return null; } if(size == 1) { r.add(new ArrayList<Integer>()); r.get(0).add(val); return r; } for (int i = start; i <= val/size; i++) { ArrayList<ArrayList<Integer>> tr = Partition(val - i, i, size - 1); if (tr != null) { for (int j = 0; j < tr.size(); j++) { ArrayList<Integer> subr = tr.get(j); subr.add(i); } r.addAll(tr); } } return r; } On Sun, Feb 6, 2011 at 7:51 AM, Gajendra Dadheech <gajju3...@gmail.com>wrote: > Write a function to print all unique partitions on n tht are of size m. eg: > n=10, m=4. it should print 7 1 1 1, 6 2 1 1, 5 3 1 1, 3 3 2 2,, so on > > > > Thanks and regards, > Gajendra Dadheech > hi > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.