Recursive Algorithm for Generating Partitions of an Integer. 1 Preliminary

Similar documents
Infinite Sequences and Series

Lecture 2 Clustering Part II

De Bruijn Sequences for the Binary Strings with Maximum Density

De Bruijn Sequences for the Binary Strings with Maximum Specified Density

4.3 Growth Rates of Solutions to Recurrences

IP Reference guide for integer programming formulations.

OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES

Lecture Overview. 2 Permutations and Combinations. n(n 1) (n (k 1)) = n(n 1) (n k + 1) =

Sequences A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

Discrete-Time Systems, LTI Systems, and Discrete-Time Convolution

arxiv: v1 [math.co] 23 Mar 2016

Recurrence Relations

Counting Well-Formed Parenthesizations Easily

Commutativity in Permutation Groups

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)

Analysis of Algorithms. Introduction. Contents

Math 155 (Lecture 3)

Lecture 11: Pseudorandom functions

Sequences I. Chapter Introduction

On the Linear Complexity of Feedback Registers

Square-Congruence Modulo n

62. Power series Definition 16. (Power series) Given a sequence {c n }, the series. c n x n = c 0 + c 1 x + c 2 x 2 + c 3 x 3 +

Math 475, Problem Set #12: Answers

6 Integers Modulo n. integer k can be written as k = qn + r, with q,r, 0 r b. So any integer.

MA131 - Analysis 1. Workbook 2 Sequences I

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

NEW FAST CONVERGENT SEQUENCES OF EULER-MASCHERONI TYPE

THE ASYMPTOTIC COMPLEXITY OF MATRIX REDUCTION OVER FINITE FIELDS

The picture in figure 1.1 helps us to see that the area represents the distance traveled. Figure 1: Area represents distance travelled

Alliance Partition Number in Graphs

2.4 - Sequences and Series

2.4 Sequences, Sequences of Sets

Parallel Vector Algorithms David A. Padua

Rademacher Complexity

Optimization Methods: Linear Programming Applications Assignment Problem 1. Module 4 Lecture Notes 3. Assignment Problem

Sums, products and sequences

The Rand and block distances of pairs of set partitions

Approximate Sorting. Institute for Theoretical Computer Science, ETH Zürich, CH-8092 Zürich

An Introduction to Randomized Algorithms

Lecture 9: Pseudo-random generators against space bounded computation,

Generating Functions. 1 Operations on generating functions

HOMEWORK 2 SOLUTIONS

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 17 Lecturer: David Wagner April 3, Notes 17 for CS 170

Induction: Solutions

Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication

Section 5.1 The Basics of Counting

Math 2784 (or 2794W) University of Connecticut

Rank Modulation with Multiplicity

The Discrete Fourier Transform

A GENERALIZATION OF THE SYMMETRY BETWEEN COMPLETE AND ELEMENTARY SYMMETRIC FUNCTIONS. Mircea Merca

Merge and Quick Sort

Randomized Algorithms I, Spring 2018, Department of Computer Science, University of Helsinki Homework 1: Solutions (Discussed January 25, 2018)

Lecture 9: Hierarchy Theorems

Polynomial identity testing and global minimum cut

Dominating Sets and Domination Polynomials of Square Of Cycles

Lecture 14: Randomized Computation (cont.)

A Note on the Symmetric Powers of the Standard Representation of S n

7. Modern Techniques. Data Encryption Standard (DES)

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro

Beurling Integers: Part 2

Math 172 Spring 2010 Haiman Notes on ordinary generating functions

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ.

A representation approach to the tower of Hanoi problem

MAT1026 Calculus II Basic Convergence Tests for Series

Algebra of Least Squares

n k <. If an even palindrome subsequence consists 2

A Combinatoric Proof and Generalization of Ferguson s Formula for k-generalized Fibonacci Numbers

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.

Chapter 6. Advanced Counting Techniques

Lecture 10: Mathematical Preliminaries

V. Adamchik 1. Recursions. Victor Adamchik Fall of x n1. x n 2. Here are a few first values of the above sequence (coded in Mathematica)

University of Twente The Netherlands

Design and Analysis of Algorithms

The Minimum Distance Energy for Polygonal Unknots

Polynomial Multiplication and Fast Fourier Transform

CS / MCS 401 Homework 3 grader solutions

SOME TRIBONACCI IDENTITIES

CALCULATION OF FIBONACCI VECTORS

Algorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources

Lesson 10: Limits and Continuity


Week 5-6: The Binomial Coefficients

Fundamenta Informaticae XXI (2001) IOS Press

Hoggatt and King [lo] defined a complete sequence of natural numbers

UNIT #5. Lesson #2 Arithmetic and Geometric Sequences. Lesson #3 Summation Notation. Lesson #4 Arithmetic Series. Lesson #5 Geometric Series

Mathematical Induction

Lecture Notes for CS 313H, Fall 2011

LONG SNAKES IN POWERS OF THE COMPLETE GRAPH WITH AN ODD NUMBER OF VERTICES

Axioms of Measure Theory

The r-generalized Fibonacci Numbers and Polynomial Coefficients

Geometry of LS. LECTURE 3 GEOMETRY OF LS, PROPERTIES OF σ 2, PARTITIONED REGRESSION, GOODNESS OF FIT

Algorithm Analysis. Chapter 3

Pairs of disjoint q-element subsets far from each other

Homework 9. (n + 1)! = 1 1

6.883: Online Methods in Machine Learning Alexander Rakhlin

Model of Computation and Runtime Analysis

subcaptionfont+=small,labelformat=parens,labelsep=space,skip=6pt,list=0,hypcap=0 subcaption ALGEBRAIC COMBINATORICS LECTURE 8 TUESDAY, 2/16/2016

Context-free grammars and. Basics of string generation methods

Transcription:

Recursive Algorithm for Geeratig Partitios of a Iteger Sug-Hyuk Cha Computer Sciece Departmet, Pace Uiversity 1 Pace Plaza, New York, NY 10038 USA scha@pace.edu Abstract. This article first reviews the problem of partitioig a positive iteger i geeral. Ad the recursive algorithms for, geeratig exactly k partitios of a positive umber are preseted. The most efficiet recursive algorithm s computatioal ruig time is Θ(k p() which is the lower boud of problem. 1 Prelimiary A positive iteger ca be represeted by sums of positive iteger terms. For example of = 5, there are 7 differet ways as listed i Table 1. Table 1. 5) ad 5, example 5 = 1 + 1 + 1 + 1 + 1 5,5) = {<1,1,1,1,1>} = 2 + 1 + 1 + 1 5,4) = {<2,1,1,1>} = 3 + 1 + 1 = 2 + 2 + 1 5,3) = {<2,2,1>, <3,1,1>} = 4 + 1 = 3 + 2 5,2) = {<3,2>, <4,1>} = 5 5,1) = {<5>} This classic problem of geeratig partitios of a positive iteger is formally defied i eq(1) ) { l l( l l( l( iteger{1,..., } l( l( j) if i j} Let l( deotes the i th elemet i the list l. ) is a set of ordered list l whose elemets l( s are positive itegers ad their sum is exactly. Ay permutatio of l is cosidered to be the same, e.g., (2 + 2 + 1) = (1 + 2 + 2) = (2 + 1 + 2). Hece, oly the sorted lists are icluded i the output set. A simple biary tree to geerate all partitios of all itegers is depicted i [1] ad Figure 1 (a). The algorithm is give below where +(l x, l y ) is cocateatig two lists ad l(1~ l -1) is a sub list of l startig from the fist elemet to l -1 th elemet, e.g., +(<3,3>,) = <3,3,1> = l x ad l x (1~2) = <3,3>. Algorithm 0: *) where 1. the root is 2. geerate childre by eqs (2) ad (3) for all odes, recursively. L ( l) ( l, 1 ) (2) ( l(1 ~ l 1), l( l ) 1 ) if l( l ) l( l 1 ) R ( l) (3) abort otherwise (1)

<1,1,1> <1,1> <2> <2,1> <3> 1) 2) 3) <1,1,1,1> <2,1,1> <2,2> <3,1> <4> <1,1,1,1,1> <2,1,1,1> <2,2,1> <3,1,1> <3,2> <4,1> <5> <1,1,1,1,1,1> <2,1,1,1,1> <2,2,1,1> <2,2,2> <3,1,1,1> <3,2,1> <3,3> <4,1,1> <4,2> <5,1> <6> (a) 4) 5) 6) <1,1,1,1,1,1> <2,1,1,1,1> <2,2,1,1> <3,1,1,1> <2,2,2> <3,2,1> <4,1,1> <3,3> <4,2> <5,1> 6,6) 6,5) 6,4) 6,3) 6,2) 7,4) 1 1 1 1 1 1 1 <4,1,1,1> 1 1 1 1 1 1 1 <3,2,1,1> 1 1 1 1 1 1 1 <2,2,2,1> <6> 6,1) (b) (c) Figure 1. (a) a biary tree for *), (b) a biary tree for 6), ad (c) 7,4) with bars. ) for ay ca be geerated together with all s for i < usig the Algorithm 0, yet aother more efficiet algorithm to geerate oly ) is depicted as a simple biary tree i [1] ad a example is show i Figure 1 (b). Let deote a set of ordered list l whose legth is exactly k, i.e., the positive iteger is expressed exactly k partitios as formally defied i eq(4) ad some examples are give i Table 2. k { l l(1),, l( l( l( iteger{1,..., } l( l( j) if i j} (4) i1 k1 ) (5) Notice that k th level i the biary tree i Figure 1 (b) cotais ad thus ca be computed usig the respective algorithm, yet oe must geerate 1)~k1) i order to geerate. Aother way to thik of the problem is usig k 1 bars to separate items ito k partitios. Table 2. Examples of 15,2) 9,3) 9,4) 9,5) 8,3) 8,4) 8,5) 7,3) 7,4) <8,7> <9,6> <10,5> <11,4> <12,3> <13,2> <14,1> <3,3,3> <4,3,2> <4,4,1> <5,2,2> <5,3,1> <6,2,1> <7,1,1> <3,2,2,2> <3,3,2,1> <4,2,2,1> <4,3,1,1> <5,2,1,1> <6,1,1,1> <2,2,2,2,1> <3,2,2,1,1> <3,3,1,1,1> <4,2,1,1,1> <5,1,1,1,1> <3,3,2> <4,2,2> <4,3,1> <5,2,1> <6,1,1> <2,2,2,2> <3,2,2,1> <3,3,1,1> <4,2,1,1> <5,1,1,1> <2,2,2,1,1> <3,2,1,1,1> <4,1,1,1,1> <3,2,2> <3,3,1> <4,2,1> <5,1,1> <2,2,2,1> <3,2,1,1> <4,1,1,1>

Geeratig is ot oly a importat umber theory problem, but also plays a key role i umerous applicatio problems. Albeit a efficiet was developed i 1779 ad described i [1], here recursive algorithms are preseted ot oly to provide a recursive defiitio of the problem, but also to reaso its efficiecy. 2 Desigig Recursive Algorithms Before embarkig o the algorithm, it is ecessary to defie some cocateate fuctios. The fuctio +(x,l), takes a iteger x ad L, a set of ordered lists of itegers as iputs as defied i eq(6). A ew set of lists are produced by isertig x i the head of each list i L as exemplified i eq(7). Isertig a elemet i the begiig of a list takes a costat computatioal time [2]. ( x, L) { x, l(1),, l( l ) l L} (6) 4,6,1,1 6,1,1 4,5,2,1 5,2,1 4,4,3,1 (4, 4,3,1 ) 4,4,2,2 4,2,2 4,3,3,2 3,3,2 Some of the lists i the output set i eq(6) may ot be ordered lists aymore. Hece, let s defie a ew fuctio (x,l) which excludes such cases as defied i eq(8). ( x, L) { x, l(1),, l( l ) l L l(1) x} (8) (7) 6,1,1 4,4,3,1 5,2,1 4,4,2,2 (4, 4,3,1 ) 4,3,3,2 4,2,2 3,3,2 (9) 3,1,1 (1, ) (10) 2,2,1 The output of may be a empty set as i eq(10). Note that (4,) returs <4>. Let (x,l) be idetical to (x,l) except that (4,) returs istead of <4>. ( x, L) { x, l(1),, l( l ) l L l(1) x} if L otherwise Usig the (x,l) fuctio = {(1, 1,k1), (2, 2,k1),, ( k1))} ad thus, a recursive ad algorithmic defiitio of ca be writte as i eq(12). Algorithm I: eq(12) (11) i1 ( i, i, k 1)) if k if k 1& k if k 1& k (12)

Oe should ot geerate the Fiboacci sequece umber by its recursive defiitio as it would take Θ(φ ). Similarly, the eq(12) is a soud recursive defiitio of but ufortuately Algorithm I makes too may uecessary recursive procedure calls as show i Figure 2 (a). Oe quick observatio from Figure 2 (a), k+1 upper boud ca be used to reduce the uecessary recursive calls. Theorem 1. i,k1) = if i > k+1. Proof. If i = k+1+ ε where ε 1, ( k+1+ ε), = k 1 ε,. Sice (k 1 ε) < (, i,k1) =. Istead of checkig all itegers from 1 to as i Algorithm I, oly from 1 to k+1 ca be checked. Usig the Theorem 1, Algorithm II is give i eq (13) Algorithm II: usig k+1 upper boud i eq(13) k1 i1 ( i, i, k 1)) if k 1 if k 1 (13) Notice that is used istead of sice the upper boud guaratees that ever returs a empty set because is always greater tha or equal to k. The recursive call diagram of Algorithm II for 6,4) is show i Figure 2 (b). Oce agai the eq(13) may be a better defiitio for tha the eq(4) which is a o-algorithmic defiitio yet Algorithm II still makes too may uecessary recursive calls. Aother upper boud ca be oticed from Figure 2(b); 3,2) i (1,3,2)) makes two recursive calls: (1,2,1)) ad (2,1,1)). Notice that (1, (2,1,1))) will retur always a empty set because the output list <,1,2, > is ot ordered. Theorem 2. (s, (j, j,) = if j > s Proof. Let j = s+ ε where ε 1. +(s, + (s+ ε, c+ ε, ) will retur < c, c+ ε, > which is ot a ordered list. Hece, (c, (c+ ε, c+ ε, ) = The value s i the paret level ca be aother upper boud for a give recursive procedure to avoid uecessary childre procedures. The value c must be passed to its childre recursive procedures as a extra parameter ad the recursive procedure must choose the miimum of two upper boud values. Hece, the followig Algorithm III has two parts: oe is the iitial call part i eq(14) ad the other is recursive procedure with a extra parameter part i eq(15). Algorithm III: usig the miimum of two upper bouds: eq(14) followed by eq(15) if k P ( (14) Q( k, k 1) otherwise if k 1 s Q( k, s) ( i, Q( i, k 1, mi( i, i k 2))) if k 1 (15) i1 Figure 2 (c) shows the recursive call diagram of Algorithm III for 6,4). It is much more efficiet tha Algorithm I ad II yet ca be improved further.

6,4) 6,4) 6,4) = Q(6,4,3) Q(6,4,3) (1, 5,3)) (1,4,2)) (1,3,1)) 3,1) = 3 <1,1,1,3> (2,2,1)) 2,1) = 2 <1,1,2,2 > (3,1,1)) 1,1) = 1 <1,1,3,1 > (4,0,1)) (2,3,2)) (1,2,1)) 2,1) = 2 <1,2,1,2> (2,1,1)) 1,1) = 1 <1,2,2,1> (3,0,1)) (3,2,2)) (1,1,1)) 1,1) = 1 <1,3,1,1> (4,1,2)) (2,0,1)) (5,0,2)) (2, 4,3)) (1,3,2)) (1,2,1)) (2,1,1)) 2,1) = 2 1,1) = 1 <2,1,1,2> <2,1,2,1> (3,0,1)) (2,2,2)) (1,1,1)) 1,1) = 1 <2,2,1,1> (3,1,2)) (2,0,1)) (4,0,2)) (3, 3,3)) (1,2,2)) (1,1,1)) 1,1) = 1 <3,1,1,1> (2,1,2)) (3,0,2)) (4, 2,3)) (5, 1,3)) (6, 0,3)) (a) Algorithm I (1,5,3)) (2,4,3)) (3,3,3)) (1,Q(5,3,1)) (2, Q(4,3,2)) (3, Q(3,3,1)) 6,4) = R(6,4,3) R(6,4,3) +(2,R(4,3,2)) +(3,R(3,3,1)) (1,4,2)) (2,3,2)) (3,2,2)) (1,3,1)) 3,1) = 3 (1,1,1,3) (2,2,1)) 2,1) = 2 (1,1,2,2) (3,1,1)) 1,1) = 1 (1,1,3,1) (1,2,1)) 2,1) = 2 (1,2,1,2) (2,1,1)) 1,1) = 1 (1,2,2,1) (1,1,1)) 1,1) = 1 (1,3,1,1) (1,3,2)) (1,2,1)) 2,1) = 2 (2,1,1)) 1,1) = 1 (2,2,2)) (1,1,1)) 1,1) = 1 (1,2,2)) (1,1,1)) 1,1) = 1 (b) Algorithm II (1, Q(4,2,1)) (1, Q(3,1,1)) Q(3,1,1) = 3 (1, Q(3,2,1)) (1, Q(2,1,1)) Q(2,1,1) = 2 (2, Q(2,2,1)) (1, Q(1,1,1)) Q(1,1,1) = 1 (1, Q(2,2,1)) (1, Q(1,1,1)) Q(1,1,1) = 1 (c) Algorithm III +(2,R(2,2,1)) +(1,R(1,1,1)) R(1,1,1) = 1 +(1,R(2,2,1)) +(1,R(1,1,1)) R(1,1,1) = 1 (d) Algorithm IV Figure 2. recursive procedure call diagrams for 6,4). (2,1,1,2) (2,1,2,1) (2,2,1,1) (3,1,1,1) (1,1,1,3) (2,1,1,2) (2,2,1,1) (3,1,1,1) (2,2,1,1) (3,1,1,1)

So far, oly the upper boud values have bee utilized i Algorithm II ad III, a lower boud, ceil(/ ca be observed from Figure 2. I order to cover with k partitios, the first partitio s size must be at least ceil(/. Theorem 3. ( i, i, k 1)) if i k Proof. Suppose the first partitio s size is i < ceil(/. The the remaiig partitios size must be less tha or equal to i. If all partitios sizes are equal to i, the total size is the maximum ad it is k i. But k i < because ceil(/. i i i r k The followig Algorithm IV utilizes both upper boud ad lower boud. Algorithm IV: Algorithm III + lower boud: eq(16) followed by eq(17) if k P ( (16) R( k, k 1) otherwise if k 1 ( s R k, s) ( i, R( i, k 1, mi( i, i k 2))) if 1 k (17) i k Figure 2(d) ad Figure 3 show the recursive procedure call diagram of Algorithm IV. Note that +(x,l) fuctio is used istead because the lower boud guaratees that all l(1) s are less tha or equal to x. R(12,4,9) 3 R(9,3,3) <3,3,3> 3 R(6,2,3) <3,3> 3 R(3,1,3) <3> <3,3,3,3> <4,3,3,2> <4,4,2,2> <4,4,3,1> <5,3,2,2> <5,3,3,1> <5,4,2,1> <5,5,1,1> <6,2,2,2> <6,3,2,1> <6,4,1,1> <7,2,2,1> <7,3,1,1> <8,2,1,1> <9,1,1,1> 4 R(8,3,4) <3,3,2> 3 R(5,2,3) <4,2,2> <4,3,1> 4 R(4,2,2) 5 R(7,3,5) 6 R(6,3,4) <3,2,2> <3,3,1> <4,2,1> <5,1,1> <2,2,2> <3,2,1> <4,1,1> 4 R(3,2,2) 5 R(2,2,3) 3 R(2,1,2) 2 R(2,1,2) 3 R(1,1,1) 3 R(4,2,3) <2,2> 2 R(2,1,2) <3,1> 3 R(2,1,2) 3 R(3,2,2) 4 R(2,2,1) <3,2> <2,2> <3,1> <2,1> <1,1> 2 R(1,1,1) 1 R(1,1,1) 2 R(4,2,2) <2,2> 2 R(2,1,2) <2,1> <1,1> 2 R(1,1,1) 1 R(1,1,1) <2> <2> <2> <2> 7 R(5,3,3) <2,2,1> <3,1,1> 2 R(3,2,2) <2,1> 2 R(1,1,1) 3 R(2,2,1) <1,1> 1 R(1,1,1) 8 R(4,3,2) <2,1,1> 2 R(2,2,1) <1,1> 1 R(1,1,1) 9 R(3,3,1) <1,1,1> 1 R(2,2,1) <1,1> 1 R(1,1,1) Figure 3. The recursive procedure call diagram of Algorithm IV for 12,4).

p( 3 Computatioal Complexity p() is widely kow as the iteger partitio fuctio which is a way of writig as a sum of positive itegers [3,4]. I other words, p() is the cardiality of ); p() = ). Let p( =. Fidig p() or p( such as p(27,8) = 352, p(31,5) = 427, ad some examples i Table 3 is a importat problem ad has bee widely studied i depth. It ca be computed much faster without computig [3,4]. We will ot cosider the algorithm for geeratig p() here but use it to state the computatioal complexity of Algorithm IV. p( ) p( (18) k1 Table 3. Cardiality p( \k 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 p() 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 3 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 1 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 1 2 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 7 6 1 3 3 2 1 1 0 0 0 0 0 0 0 0 0 0 0 11 7 1 3 4 3 2 1 1 0 0 0 0 0 0 0 0 0 0 15 8 1 4 5 5 3 2 1 1 0 0 0 0 0 0 0 0 0 22 9 1 4 7 6 5 3 2 1 1 0 0 0 0 0 0 0 0 30 10 1 5 8 9 7 5 3 2 1 1 0 0 0 0 0 0 0 42 11 1 5 10 11 10 7 5 3 2 1 1 0 0 0 0 0 0 56 12 1 6 12 15 13 11 7 5 3 2 1 1 0 0 0 0 0 77 13 1 6 14 18 18 14 11 7 5 3 2 1 1 0 0 0 0 101 14 1 7 16 23 23 20 15 11 7 5 3 2 1 1 0 0 0 135 15 1 7 19 27 30 26 21 15 11 7 5 3 2 1 1 0 0 176 16 1 8 21 34 37 35 28 22 15 11 7 5 3 2 1 1 0 231 17 1 8 24 39 47 44 38 29 22 15 11 7 5 3 2 1 1 297 The output set size of is k p( ad hece the computatioal ruig time complexity of ay algorithm is Ω(k p() which is the lower boud. Note that Algorithm IV makes exactly p( umber of cocateate fuctios for each level. There are k levels ad thus Algorithm IV takes Θ(k p(). All Algorithms I, II, ad III takes Ω(k p(). It should be oted that p( grows very fast as depicted i Figure 4. Geeratig ) takes expoetial, O( p()) by the eq(19), a.k.a. the Hardy ad Ramauja asymptotic formula [3,4]. 2 3 1 p( ) e (19) 4 3 10000 8000 k = 2 k = 3 k = 4 k = 5 6000 4000 2000 0 0 10 20 30 40 50 60 70 80 90 100 Figure 4. p(2), p(3), p(4), p(5) plots

4 Discussio Recursive thikig ofte sheds some light o how to defie ad solve a difficult problem. This paper preseted four recursive algorithms for. Naïve recursive algorithms are itroduced to devise a excellet recursive algorithm. It is ofte a good strategy ad tactic to desig a algorithm for a difficult problem. is about distributig ulabeled tasks to exactly k ulabeled processors. No idle processor is allowed. If processors are labeled, the order matters, e.g., <2,2,1> <2,1,2> <1,2,2>. Let O( be a way of distributig ulabeled tasks to exactly k labeled processors. To geerate O(, Algorithm II ca be used by replacig with + fuctio. Algorithm V: k1 O( ( i, O( i, k 1)) i1 if k 1 if k 1 Refereces 1. Doald E. Kuth, The Art of Computer Programmig, Volume 4, Fascicle 3: Geeratig All Combiatios ad Partitios, 2005 2. Thomas H. Corme Charles E. Leiserso Roald L. Rivest ad Clifford Stei Itroductio to Algorithms, 2 d ed., MIT Press, 2001 3. George E. Adrews ad Kimmo Eriksso Iteger Partitios, Cambridge Uiversity Press 2004 4. George E. Adrews, The Theory of Partitios, Cambridge Uiversity Press 1998