79
GENERATING COMBINATORIAL OBJECTS A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth City State University, Elizabeth City, North Carolina A Thesis Submitted to the Faculty of Old Dominion University in Partial Fulfillment of the Requirements for the Degree of MASTERS OF SCIENCE COMPUTER SCIENCE OLD DOMINION UNIVERSITY May 2014 Approved by: ________________________ Stephan Olariu (Director) ________________________ Michelle C. Weigle (Member) ________________________ Hussein A. Wahab (Member)

GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

GENERATING COMBINATORIAL OBJECTS –

A NEW PERSPECTIVE

by

Alexander Chizoma Nwala

B.Sc. December 2011, Elizabeth City State University, Elizabeth City, North Carolina

A Thesis Submitted to the Faculty of

Old Dominion University in Partial Fulfillment of the

Requirements for the Degree of

MASTERS OF SCIENCE

COMPUTER SCIENCE

OLD DOMINION UNIVERSITY

May 2014

Approved by:

________________________

Stephan Olariu (Director)

________________________

Michelle C. Weigle (Member)

________________________

Hussein A. Wahab (Member)

Page 2: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

ABSTRACT

GENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE

Alexander Chizoma Nwala

Old Dominion University, 2014

Director: Dr. Stephan Olariu

Combinatorics is the science of “possibilities.” This definition, while not formal is

a fair statement because all too often, in order to gain insight into the solution of many

counting problems, we explore the possibilities. In some cases we seek to know how many

options, while in other cases we seek to enumerate or list the options. Irrespective of the

scenario, combinatorics plays a vital role today. In many instances such as exploring the

options for choosing a new password for a combination lock, we employ combinatorics. In

considering the possible license plate permutations for a state, or to see if we have enough

IP addresses or telephone numbers, we employ combinatorics. In fact, our DNA in the

nucleus of our cells are combinatorial objects consisting of permutations with repetitions

of nucleobases represented as (G - Guanine, A - Adenine, T - Thymine, C - Cytosine). So

it is also fair to say combinatorics is part of our life. Combinatorics (the branch of

mathematics that deals with the arrangement of objects), offers many different ways of

counting such as combinations – the focus of this research effort. Combinations refer to a

special way of arranging objects when order is not considered. Combinations also belong

to the class of fundamental combinatorial objects, which is no surprise why we already

have many algorithms which generate combinations. However, these algorithms generate

combinations directly, meaning they are bound to have only one way of arranging their

Page 3: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

tuples. In contrast, this research effort offers a new way of generating combinations, an

indirect way. The indirect way offers a means by which the generator can define the order

of tuples. This new way depends on two combinatorial objects: a parent combinatorial

method, M1 (an original non-recursive constant amortized time algorithm for generating

permutations with repetitions allowed), and an indexing combinatorial method (Algorithm

f) which generates a pattern that can be translated to indices corresponding to the location

of combinations in M1.

Page 4: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

iv

Copyright, 2014, by Alexander Chizoma Nwala, All Rights Reserved.

Page 5: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

v

This thesis is dedicated to Comfort

Page 6: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

vi

ACKNOWLEDGMENTS

I acknowledge the exceptional guidance, patience and instruction of my thesis

supervisor Dr. Stephan Olariu, as well as the essential input and support of Dr. Michelle

C. Weigle and Dr. Hussein Abdel-Wahab of my thesis committee.

I remain grateful to my cousin Dr. Kingsley Nwala, without whom I will not be

where I am. I remain grateful to Dr. Ellis Lawrence and Ajay Gupta for exposing me to

research, Dr. Jamiiru Luttamaguzi for his unyielding guidance and Mr. Antonio Rook for

guiding me when I was a very young student.

Finally and most importantly, I remain grateful to God, and I acknowledge the

uncompromising support of my Father, Alexander E. Nwala, and the rest of my family.

Page 7: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

vii

TABLE OF CONTENTS

Page

LIST OF FIGURES ........................................................................................................... ix

Chapter

1. INTRODUCTION ...........................................................................................................1

1.1 MOTIVATION ..................................................................................................2

2. BACKGROUND .............................................................................................................3

2.1 PERMUTATIONS .............................................................................................3

2.2 COMBINATIONS .............................................................................................5

2.3 REPRESENTING COMBINATORIAL OBJECTS .........................................7

2.4 PROPERTIES OF COMBINATORIAL ALGORITHMS ..............................12

2.5 MORE ON PLACING BALLS INTO BINS ..................................................14

2.6 COST METRIC ...............................................................................................17

3. STATE OF THE ART. ..................................................................................................18

3.1 ALGORITHM 1...............................................................................................18

3.2 ALGORITHM 2...............................................................................................19

3.3 ALGORITHM 3...............................................................................................20

3.4 ALGORITHM 4...............................................................................................21

3.5 ALGORITHM 5...............................................................................................22

4. STUDY OF THE DERIVATION OF M1 .....................................................................26

4.1 PROPERTIES OF M1 .....................................................................................31

5. STUDY TO FIND COMBINATIONS PATTERN IN M1 ...........................................33

6. TRANSLATION OF PATTERN TO ID-VARIANT 2 SOLUTION ...........................48

6.1 TRANSLATION METHOD 1 ........................................................................48

6.2 TRANSLATION METHOD 2 ........................................................................51

6.3 SUBSTITUTION INTO M1 ............................................................................53

7. BIJECTION, COST ANALYSIS AND GENERATIONG COMBINATIONS WITH

F f ..............................................................................................................................56

7.1 BIJECTION BETWEEN ID-VARIANT 2 AND COMBINATIONS ............56

7.2 COST ANALYSIS...........................................................................................56

7.3 GENERATING COMBINATIONS WITH f...................................................59

8. APPLICATIONS ...........................................................................................................60

8.1 ALGORITHM f FOR STEM CELL RESEARCH ..........................................60

Page 8: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

viii

8.2 M1 FOR IMPLEMENTING LICENSE PLATE SERIAL FORMAT ............61

9. CONCLUSION ..............................................................................................................65

REFERENCES ..................................................................................................................67

VITA ..................................................................................................................................69

Page 9: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

ix

LIST OF FIGURES

Figure Page

1. Permutations of Three Colored Balls .................................................................... 3

2. Four-Digit Password Choices ............................................................................... 4

3. Permutations (Left) and Combinations (Right) Over the Same Set ..................... 5

4. Specific Configuration When n = 3 and k = 3 ..................................................... 6

5. Combinations When Repetition Is Allowed In SB Notation: n = 4, k = 3 ........... 7

6. Different Ways to Represent Combinatorial Objects ........................................... 9

7. Translation of a Combinatorial Object ................................................................. 10

8. All possible Paths in a 3 × 3 Grid ......................................................................... 11

9. (73) Combinations in Lex, CoLex, Gray code and Cool-lex Order ...................... 13

10. Placing Distinguishable Balls into Distinguishable Bins ..................................... 14

11. Placing Distinguishable Balls into Distinguishable Bins (Variant 2) ................... 15

12. Algorithm 1, Generating All Combinations in Lex Order .................................... 18

13. Algorithm 2, Generating All Combinations in Lex Order .................................... 19

14. Algorithm 3, Generating Combinations in Colex Order ....................................... 20

15. Algorithm 4, Generating Combinations in Gray Code Order ............................... 21

16. Revolving Door Combinations in Gray Code Order ............................................ 22

17. Combinations; (63) ................................................................................................ 23

18. Direct Method of Generating Combinations......................................................... 25

19. Indirect Method of Generating Combinations ...................................................... 25

20. Study of the Derivation of M1 .............................................................................. 27

Page 10: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

x

21. Non-Recursive Method for Generating Permutations (Repetitions Allowed) – M1

............................................................................................................................... 30

22. SB and M1 Pattern for Placing Five Balls into Two Bins in Bar Position Notation

(BPN) .................................................................................................................... 34

23. M1 Pattern for Placing Five Balls into Three Bins in BPN .................................. 34

24. M1 Pattern for Placing Five Balls into Four Bins in BPN .................................... 35

25. M1 Pattern for Placing Five Balls into Five Bins in BPN .................................... 36

26. Algorithm f ............................................................................................................ 44

27. Translated Pattern for n = 5, y = 2 ....................................................................... 49

28. Translation of Pattern When n = 5, y = 4 ............................................................. 51

29. Substitution into M1 Resulting from Translating p When n = 5 and k = 4 ......... 54

30. f Output for (73) in Four Different Orders ............................................................ 59

31. Prefixes of License Plate Serial Format ................................................................ 62

32. Suffixes of License Plate Serial Format................................................................ 63

33. List of License Plate Serials .................................................................................. 64

Page 11: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

1

CHAPTER 1

INTRODUCTION

Since we live in a world of finite resources, the science of counting is very crucial

in our daily lives. Especially because the solution to many problems take the shape of

counting. For example, given the Virginia license plate format: 𝐴𝐵𝐶 − 1234, the

multiplication rule of counting tells us that there are 175,760,000 (263 × 104) license

plate choices without restriction to special characters or profanities. By means of

generating permutations with repetitions allowed, we can see that the license plate choices

begin with 𝐴𝐴𝐴 − 0000 and end with 𝑍𝑍𝑍 − 9999. The same multiplication rule tells us

that there are 4,294,967,296 (232) possible address spaces in IPv4. When we want to

know the different possible three committee members from a group of six faculty, we

employ the basic combinations rule to find out that there are 20 such combinations. In the

foregoing instances, knowing the cardinality may be a sufficient solution, but in some other

cases such as enumerating all the two-digit permutations, (as may be the case when the last

two digits of an important phone number is missing), knowing by virtue of the

multiplication rule that we must call 100 people before we find the right person is not

enough. Instead we must enumerate all such two-digit permutations starting with 00 and

ending with 99. Another case wherein enumeration is useful is the case of enumerating all

four-letter permutations, to discover the password of a simple combination lock. In this

case, knowing we have to exhaust 10,000 possibilities is not sufficient, instead we must

know the possibilities, and prefer a systematic means of generating these possibilities.

Page 12: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

2

These counting methods discussed, belong to the field of mathematics called

combinatorics. Combinatorics deals with the arrangement of objects.

1.1 MOTIVATION

Combinatorics and its elementary elements such as permutations and combinations are

ubiquitous and crucial in mathematics. From the gamblers of the seventeenth century who

sought to understand the sample space wherein their fate was bound, to brute force attack

algorithms, combinatorics is inescapable. And any contribution to this very crucial branch

of mathematics is bound to be useful. Consequently, the goal of this research effort is to

contribute a new perspective of generating combinatorial objects, by focusing on

combinations: So far, algorithms which generate combinations do so directly, thus binding

the order of their tuple to a specific order. This research effort proposes a new way of

looking at combinations – as objects belonging to a larger set of combinatorial objects.

Therefore, combinations can be harvested from the parent combinatorial object. And if the

means to harvest combinations is based on indexing the position of combinations in the

parent combinatorial object, then the resulting combinations generation algorithm is not

bound to a specific tuple order.

Page 13: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

3

CHAPTER 2

BACKGROUND

The fundamental science of counting is as old as mathematics. In many sciences,

counting remains the most basic form of keeping track of objects. Enumeration, which is

the counting of objects with specific properties and constraints is an important branch of

combinatorics – the branch of mathematics that deals with the arrangement of objects.

Combinatorics offers many different ways of counting such as permutations and

combinations which offer solutions to many counting problems. Permutations and

combinations also belong the class of elementary combinatorial objects.

2.1 PERMUTATIONS

A permutation refers to a specific order from the ordered arrangement of objects.

Given the finite set of all possible ways of arranging some arbitrary set of objects, an item

of the set is called a permutation. For example, given three balls (red, green, and blue), let

us consider the different ways the set of three balls can be arranged:

1

2

3

4

5

6

Fig.1 Permutations of Three Colored Balls

Page 14: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

4

From Fig. 1, it is seen that there are six ways of arranging or permuting three different

objects. Thus, we can say that there are six elements in the set resulting from the three-

permutations of a set of six unique elements or 𝑃(6,3) = 6.

𝐺𝑖𝑣𝑒𝑛 𝑘, 1 ≤ 𝑘 ≤ 𝑛, 𝑃(𝑛, 𝑘) = 𝑛(𝑛 − 1)(𝑛 − 2)(𝑛 − 3)… (𝑛 − 𝑘 + 1) (1)

𝑟𝑒𝑝𝑟𝑒𝑠𝑒𝑛𝑡𝑠 𝑡ℎ𝑒 𝑐𝑎𝑟𝑑𝑖𝑛𝑎𝑙𝑖𝑡𝑦 𝑜𝑓 𝑘 𝑝𝑒𝑟𝑚𝑢𝑡𝑎𝑡𝑖𝑜𝑛𝑠 𝑜𝑓 𝑎 𝑠𝑒𝑡 𝑜𝑓 𝑛 𝑢𝑛𝑖𝑞𝑢𝑒 𝑒𝑙𝑒𝑚𝑒𝑛𝑡𝑠

𝐺𝑖𝑣𝑒𝑛 𝑘, 0 ≤ 𝑘 ≤ 𝑛, 𝑎𝑛𝑑 0! = 1,

𝑃(𝑛, 𝑘) =𝑛!

(𝑛−𝑘)! (2)

Permutations with repetition

Some problems arise where in the permutation of k objects, n objects are always

available. This means repetitive use of an object is allowed. For example, consider a four-

digit password combination lock, let us consider all the possible four-digit password

candidates. Given that each of the four positions (p1 – p4) can be occupied by integers from

0-9:

p1 p2 p3 p4

1 0 0 0 0

2 0 0 0 1

3 0 0 0 2

4 0 0 0 3

5 0 0 0 4

6 0 0 0 5

. . . . .

. . . . .

. . . . .

10000 9 9 9 9

Fig.2 Four-Digit Password Choices

Page 15: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

5

From Fig. 2 it can be seen that there are 10,000 possible four-digit password candidates.

𝐺𝑖𝑣𝑒𝑛 𝑘 ≤ 𝑛, 𝑇ℎ𝑒𝑟𝑒 𝑎𝑟𝑒 𝑛𝑘 𝑤𝑎𝑦𝑠 𝑜𝑓 (3)

𝑝𝑒𝑟𝑚𝑢𝑡𝑖𝑛𝑔 𝑘 𝑢𝑛𝑖𝑞𝑢𝑒 𝑜𝑏𝑗𝑒𝑐𝑡𝑠 𝑓𝑟𝑜𝑚 𝑎 𝑠𝑒𝑡 𝑜𝑓 𝑠𝑖𝑧𝑒 𝑛, 𝑤ℎ𝑒𝑛 𝑟𝑒𝑝𝑒𝑡𝑖𝑡𝑖𝑜𝑛 𝑖𝑠 𝑎𝑙𝑙𝑜𝑤𝑒𝑑

2.2 COMBINATIONS

When permutations are discussed, the order of the objects of interest is significant.

This means given the strings ABC and CAB from the three-permutation of the set of

alphabets, ABC is not the same as CAB, because order is prime. However, considering the

strings ABC and CAB under the context of a combination, they are indistinguishable. This

is because a combination is a special kind permutation when order is not of importance.

For this reason, combinations are commonly referred to as unordered selections.

Reconsidering the permutations example (Fig. 1), in the context of combinations, there is

only one possible combination resulting from the selection of three objects from a three-

set (red, green, and blue) collection. This means all six possible permutations are the same

combination:

1

2

3

4

5

6

Fig.3 Permutations (Left) and Combinations (Right) Over the Same Set

As seen from Fig. 3, combinations do not take into account order unlike permutations.

1

=

Page 16: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

6

𝐺𝑖𝑣𝑒𝑛 𝑘, 0 ≤ 𝑘 ≤ 𝑛, 𝐶(𝑛, 𝑘) 𝑜𝑟 (𝑛𝑘) 𝑖𝑠 𝑑𝑒𝑓𝑖𝑛𝑒𝑑 𝑎𝑠 𝑓𝑜𝑙𝑙𝑜𝑤𝑠:

𝐶(𝑛, 𝑘) =𝑛!

𝑘!(𝑛−𝑘!) (4)

𝑟𝑒𝑝𝑟𝑒𝑠𝑒𝑛𝑡𝑠 𝑡ℎ𝑒 𝑐𝑎𝑟𝑑𝑖𝑛𝑎𝑙𝑖𝑡𝑦 𝑜𝑓 𝑘 − 𝑐𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛𝑠 𝑜𝑓 𝑛 𝑑𝑖𝑠𝑖𝑛𝑐𝑡 𝑒𝑙𝑒𝑚𝑒𝑛𝑡𝑠

𝐺𝑖𝑣𝑒𝑛 𝑘 ≤ 𝑛, (5)

𝐶(𝑛, 𝑘) = 𝐶(𝑛, 𝑛 − 𝑘) Combinations with repetition

Combinations can be considered with or without repetitions just as permutations.

However, combinations with repetitions are more intricate. Before considering

combinations with repetitions, the following problem and its respective notation is

presented.

Placing indistinguishable balls into distinguishable bins (ID) – Variant 1

How can n (n kinds) of indistinguishable balls be placed into k distinguishable bins

- for example, how can three (n = 3) kinds (red, green, and yellow) of balls be placed into

three (k = 3) blue bins. Fig. 4 below is a specific case where three red balls are placed

within the first bin, one yellow ball is placed within the second bin, and one green within

the last bin.

Fig.4 Specific Configuration When n = 3 and k = 3

Page 17: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

7

Stars and Bars notation (SB)

Stars and Bars [1], a notation made popular by William Feller can be used to

represent the problem of placing indistinguishable balls into distinguishable bins. Stars

represent the balls and bars - the bins. Similarly, the problem of placing n indistinguishable

balls into k distinguishable bins can be represented with n stars and k-1 bars. Fig. 4 in stars

and bars notation is:

**|*|*

The combinations problem of selecting k items from a set of n when repetition is allowed,

can be seen in terms of placing n indistinguishable balls into k distinguishable bins.

𝑇ℎ𝑒𝑟𝑒 𝑎𝑟𝑒 𝐶(𝑛 + 𝑘 − 1, 𝑘) = 𝐶(𝑛 + 𝑘 − 1, 𝑛 − 1) 𝑤𝑎𝑦𝑠 (6)

𝑜𝑓 𝑠𝑒𝑙𝑒𝑐𝑡𝑖𝑛𝑔 𝑘 𝑖𝑡𝑒𝑚𝑠 𝑓𝑟𝑜𝑚 𝑎 𝑠𝑒𝑡 𝑜𝑓 𝑛 𝑑𝑖𝑠𝑡𝑖𝑛𝑐𝑡 𝑖𝑡𝑒𝑚𝑠 𝑤𝑖𝑡ℎ 𝑟𝑒𝑝𝑒𝑡𝑖𝑡𝑖𝑜𝑛 𝑎𝑙𝑙𝑜𝑤𝑒𝑑

||****

|*|***

|**|**

|***|*

|****|

*||***

*|*|**

*|**|*

*|***|

**||**

**|*|*

**|**|

***||*

***|*|

****||

Fig.5 Combinations When Repetition Is Allowed In SB Notation: n = 4, k = 3

2.3 REPRESENTING COMBINATORIAL OBJECTS

Page 18: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

8

There are many ways of representing combinatorial objects such as stars and bars

notation, bit-string notation and subset notation. For example, given a set {1,2,3,4,5,6}, a

combination {1,3,6} - in subset notation, can be represented in binary string format as the

string below indicating the items which are “switched on”:

101001

In many instances, for readability, zeros are replaced with dots:

1.1..1

Fig. 6 outlines the various ways combinatorial objects such as combinations can be

represented.

Page 19: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

9

i BPN Bitstring Subset 1 2 3 4 5 6 7

1 1 1 1 111....

1,2,3

2 1 1 2 11.1...

1,2,4

3 1 1 3 11..1..

1,2,5

4 1 1 4 11...1.

1,2,6

5 1 1 5 11....1

1,2,7

6 1 2 2 1.11...

1,3,4

7 1 2 3 1.1.1..

1,3,5

8 1 2 4 1.1..1.

1,3,6

9 1 2 5 1.1...1

1,3,7

10 1 3 3 1..11..

1,4,5

11 1 3 4 1..1.1.

1,4,6

12 1 3 5 1..1..1

1,4,7

13 1 4 4 1...11.

1,5,6

14 1 4 5 1...1.1

1,5,7

15 1 5 5 1....11

1,6,7

16 2 2 2 .111...

2,3,4

17 2 2 3 .11.1..

2,3,5

18 2 2 4 .11..1.

2,3,6

19 2 2 5 .11...1

2,3,7

20 2 3 3 .1.11..

2,4,5

21 2 3 4 .1.1.1.

2,4,6

22 2 3 5 .1.1..1

2,4,7

23 2 4 4 .1..11.

2,5,6

24 2 4 5 .1..1.1

2,5,7

25 2 5 5 .1...11

2,6,7

26 3 3 3 ..111..

3,4,5

27 3 3 4 ..11.1.

3,4,6

28 3 3 5 ..11..1

3,4,7

29 3 4 4 ..1.11.

3,5,6

30 3 4 5 ..1.1.1

3,5,7

31 3 5 5 ..1..11

3,6,7

32 4 4 4 ...111.

4,5,6

33 4 4 5 ...11.1

4,5,7

34 4 5 5 ...1.11

4,6,7

35 5 5 5 ....111

5,6,7

Fig.6 Different Ways to Represent Combinatorial Objects

Page 20: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

10

Bar Position Notation (BPN), a notation coined in this research effort, is a

derivative of the stars and bars notation which simple takes into account the position of

bars (or 1s). For example, given the following string:

****

BPN takes into account the possible places a bar could reside:

1*2*3*4*5

Consequently, “|*|*|***” is represented as “1,2,3” in BPN.

From Fig. 6, the subset describes the combinatorial objects resulting from C(7,3). The BPN

and bit-string notations describe the combinatorial objects resulting from placing four

indistinguishable balls into four distinguishable bins. The character “1” represents the

boundary of the bins while the dots represent the balls. For this reason, the following string

”...11.1” means there are three balls in the first bin, zero balls in the second, one in the

third, and zero in the last (Fig. 7)

Finally, combinatorial objects such as combinations can be represented as paths in

an n by k grid. This is because C(n+k, k) represents all paths of length n + k consisting of

n vertical moves and k horizontal moves on the edge of an n by k grid. For example, Fig.

8 enumerates 20 (C(6, 3)) paths when n = 3 and k = 3.

...11.1 =

Fig.7 Translation of a Combinatorial Object

Page 21: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

11

000111 001011 001101 001110

010011 010101 010110 011001

110001 110010 110100 111000

011010 011100 100011 100101

100110 101001 101010 101100

Fig.8 All Possible Paths in a 3 × 3 Grid

Page 22: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

12

2.4 Properties of Combinatorial Algorithms

Algorithms which generate all tuples are typically of a recursive nature. On the

other hand, algorithms which given an input tuple and some other state information of some

variable(s), generate the next tuple, are typically of an iterative nature.

An Iterative algorithm which generates the next combination without a loop is

called loopless. And if the algorithm can begin from any point once given the input state

variables, the algorithm is said to be memoryless.

Many combinatorial algorithms generate combinatorial objects in different orders

such as Lexicographic or Lex, Colexicographic or CoLex, and Gray code orders.

Informally lexicographic order represents the order of tuples as seen from a

dictionary.

𝐺𝑖𝑣𝑒𝑛 𝑡𝑤𝑜 𝑠𝑒𝑡𝑠 𝐴 𝑎𝑛𝑑 𝐵, 𝑡ℎ𝑒 𝑙𝑒𝑥𝑖𝑐𝑜𝑔𝑟𝑎𝑝ℎ𝑖𝑐 𝑜𝑟𝑑𝑒𝑟 𝑜𝑣𝑒𝑟 𝑡ℎ𝑒 𝑐𝑎𝑟𝑡𝑒𝑠𝑖𝑎𝑛 𝑝𝑟𝑜𝑑𝑢𝑐𝑡: {𝑎, 𝑏} ≤ {𝑎′, 𝑏′} 𝑖𝑓𝑓 𝑎 < 𝑎′𝑜𝑟 𝑎 = 𝑎′𝑎𝑛𝑑 𝑏 ≤ 𝑏′ (7)

Informally, colexicographic order represents the order derived by applying the

following operations to all tuples:

a) Reflect tuples

b) Order lexicographically

c) Reflect tuples again

𝐴 𝑠𝑡𝑟𝑖𝑛𝑔 𝑎1𝑎2…𝑎𝑛 < 𝑏1𝑏2…𝑏𝑚 𝑖𝑠 𝑖𝑛 𝑅𝑒𝐿𝑒𝑥 𝑜𝑟𝑑𝑒𝑟 𝑖𝑓 𝑏1𝑏2…𝑏𝑚 < 𝑎1𝑎2…𝑎𝑛 (8)

𝐴 𝑠𝑡𝑟𝑖𝑛𝑔 𝑎1𝑎2…𝑎𝑛 < 𝑏1𝑏2…𝑏𝑚 𝑖𝑠 𝑖𝑛 𝐶𝑜𝐿𝑒𝑥 𝑜𝑟𝑑𝑒𝑟 𝑖𝑓 𝑎𝑛…𝑎2𝑎1 < 𝑏𝑚…𝑏2𝑏1 (9)

Gray code or minimal change order represents the order of tuples wherein

successive tuples differ by a constant number of bits. There are various possible gray

code orders such as the Cool-lex order [9].

Page 23: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

13

Lex Colex Gray Code Cool-lex

1 ....111 111.... 111.... 111....

2 ...1.11 11.1... 1.11... .111...

3 ...11.1 1.11... .111... 1.11...

4 ...111. .111... 11.1... 11.1...

5 ..1..11 11..1.. 1..11.. .11.1..

6 ..1.1.1 1.1.1.. .1.11.. 1.1.1..

7 ..1.11. .11.1.. ..111.. .1.11..

8 ..11..1 1..11.. 1.1.1.. ..111..

9 ..11.1. .1.11.. .11.1.. 1..11..

10 ..111.. ..111.. 11..1.. 11..1..

11 .1...11 11...1. 1...11. .11..1.

12 .1..1.1 1.1..1. .1..11. 1.1..1.

13 .1..11. .11..1. ..1.11. .1.1.1.

14 .1.1..1 1..1.1. ...111. ..11.1.

15 .1.1.1. .1.1.1. 1..1.1. 1..1.1.

16 .1.11.. ..11.1. .1.1.1. .1..11.

17 .11...1 1...11. ..11.1. ..1.11.

18 .11..1. .1..11. 1.1..1. ...111.

19 .11.1.. ..1.11. .11..1. 1...11.

20 .111... ...111. 11...1. 11...1.

21 1....11 11....1 1....11 .11...1

22 1...1.1 1.1...1 .1...11 1.1...1

23 1...11. .11...1 ..1..11 .1.1..1

24 1..1..1 1..1..1 ...1.11 ..11..1

25 1..1.1. .1.1..1 ....111 1..1..1

26 1..11.. ..11..1 1...1.1 .1..1.1

27 1.1...1 1...1.1 .1..1.1 ..1.1.1

28 1.1..1. .1..1.1 ..1.1.1 ...11.1

29 1.1.1.. ..1.1.1 ...11.1 1...1.1

30 1.11... ...11.1 1..1..1 .1...11

31 11....1 1....11 .1.1..1 ..1..11

32 11...1. .1...11 ..11..1 ...1.11

33 11..1.. ..1..11 1.1...1 ....111

34 11.1... ...1.11 .11...1 1....11

35 111.... ....111 11....1 11....1

Fig.9 (73) Combinations in Lex, CoLex, Gray code and Cool-lex Order

Page 24: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

14

2.4 MORE ON PLACING BALLS INTO BINS

The solutions to many problems present themselves as one of the different

variations of enumerating the different ways balls can be placed into bins. It must be noted

that the order in which the balls are placed within the bins does not matter. However, it

must be properly defined whether the balls and the bins are distinguishable or

indistinguishable.

Placing distinguishable balls into distinguishable bins (DD)

As seen from Fig. 10, the balls are distinguishable (red, green, and blue) as well as

the bins (B1, B2, B3, and B4). Consider a problem wherein we must count the total number

of ways four cards from a standard deck of 52 cards are to be distributed to three players.

It is clear that the cards can be seen as distinguishable balls since they are unique and the

players can be seen as distinguishable bins since they are also unique. To solve this

problem, consider that

1. 𝑇ℎ𝑒 𝑓𝑖𝑟𝑠𝑡 𝑝𝑙𝑎𝑦𝑒𝑟 𝑐𝑎𝑛 𝑏𝑒 𝑑𝑒𝑎𝑙𝑡 4 𝑐𝑎𝑟𝑑𝑠 𝑖𝑛 𝐶(52, 4) 𝑤𝑎𝑦𝑠 2. 𝑇ℎ𝑒 𝑠𝑒𝑐𝑜𝑛𝑑 𝑝𝑙𝑎𝑦𝑒𝑟 𝑐𝑎𝑛 𝑏𝑒 𝑑𝑒𝑎𝑙𝑡 4 𝑐𝑎𝑟𝑑𝑠 𝑖𝑛 𝐶(52 − 4, 4) = 𝐶(48, 4) 𝑤𝑎𝑦𝑠 3. 𝑇ℎ𝑒 𝑡ℎ𝑖𝑟𝑑 𝑝𝑙𝑎𝑦𝑒𝑟 𝑐𝑎𝑛 𝑏𝑒 𝑑𝑒𝑎𝑙𝑡 4 𝑐𝑎𝑟𝑑𝑠 𝑖𝑛 𝐶(48 − 4, 4) = 𝐶(44, 4) 𝑤𝑎𝑦𝑠 4. 𝑇ℎ𝑒 𝑓𝑜𝑢𝑟𝑡ℎ 𝑝𝑙𝑎𝑦𝑒𝑟 𝑐𝑎𝑛 𝑏𝑒 𝑑𝑒𝑎𝑙𝑡 4 𝑐𝑎𝑟𝑑𝑠 𝑖𝑛 𝐶(44 − 4, 4) = 𝐶(40, 4) 𝑤𝑎𝑦𝑠 5. 𝐵𝑎𝑠𝑒𝑑 𝑜𝑛 𝑡ℎ𝑒 𝑚𝑢𝑙𝑡𝑖𝑝𝑙𝑖𝑐𝑎𝑡𝑖𝑜𝑛 𝑟𝑢𝑙𝑒 𝑜𝑓 𝑐𝑜𝑢𝑛𝑡𝑖𝑛𝑔 𝑡ℎ𝑒𝑟𝑒 𝑎𝑟𝑒 𝑎 𝑡𝑜𝑡𝑎𝑙 𝑜𝑓

6. 𝐶(52, 4) × 𝐶(48, 4) × 𝐶(44, 4) × 𝐶(40, 4) =52!

48! 4!×

48!

44! 4!×

44!

40! 4!×

40!

36! 4!

7. 𝐶(52, 4) × 𝐶(48, 4) × 𝐶(44, 4) × 𝐶(40, 4) =52!

4! 4! 4! 4!36!

B4 B1 B2 B3

Fig.10 Placing Distinguishable Balls into Distinguishable Bins

Page 25: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

15

𝑇ℎ𝑒𝑟𝑒 𝑎𝑟𝑒𝑛!

𝑛1!𝑛2!𝑛3…𝑛𝑘! 𝑤𝑎𝑦𝑠 𝑜𝑓 𝑝𝑙𝑎𝑐𝑖𝑛𝑔 𝑛 𝑑𝑖𝑠𝑡𝑖𝑛𝑔𝑢𝑖𝑠ℎ𝑎𝑏𝑙𝑒 𝑏𝑎𝑙𝑙𝑠 𝑖𝑛𝑡𝑜 𝑘 (10)

𝑑𝑖𝑠𝑖𝑛𝑔𝑢𝑖𝑠ℎ𝑎𝑏𝑙𝑒 𝑏𝑖𝑛𝑠

Placing indistinguishable balls into distinguishable bins (ID) – Variant 2

Another variant of placing indistinguishable balls into distinguishable bins takes

into account the number of indistinguishable balls. For example, Fig. 11 describes the case

of placing four (n=4) balls into three (k=3) bins,

As seen in Fig. 11, n means n indistinguishable instances of balls (as opposed to n kinds

of balls in the Variant 1 problem).

𝑇ℎ𝑒𝑟𝑒 𝑎𝑟𝑒 (𝑛 + 𝑘 − 1𝑘 − 1

) 𝑤𝑎𝑦𝑠 𝑜𝑓 𝑝𝑙𝑎𝑐𝑖𝑛𝑔 𝑛 𝑖𝑛𝑑𝑖𝑠𝑡𝑖𝑛𝑔𝑢𝑖𝑠ℎ𝑎𝑏𝑙𝑒 𝑏𝑎𝑙𝑙𝑠 (11)

𝑖𝑛𝑡𝑜 𝑘 𝑑𝑖𝑠𝑖𝑛𝑔𝑢𝑖𝑠ℎ𝑎𝑏𝑙𝑒 𝑏𝑖𝑛𝑠

Placing distinguishable balls into indistinguishable bins (DI)

The problem of counting the placement of distinguishable balls into

indistinguishable bins is more difficult than the already visited counterparts. In fact, there

is no closed form formula to count the compartments. However, Stirling numbers of the

second kind gives us a summation expression that equals the number of ways n

distinguishable balls can be placed into k indistinguishable bins such that no bin is empty.

It must be noted that in this case, unlike the previous visited cases (DD and ID), each bin

Fig.11 Placing Distinguishable Balls into Distinguishable Bins (Variant 2)

Page 26: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

16

can contain any number of balls. For example, let us enumerate all the possible ways of

placing four different balls (1, 2, 3, 4) into three different bins:

1. {{1,2,3,4}}

2. {{1,2,3}, {4}}

3. {{1,2,4}, {3}}

4. {{1,3,4}, {2}}

5. {{2,3,4}, {1}}

6. {{1,2}, {3,4}}

7. {{1,3}, {2,4}}

8. {{1,4}, {2,3}}

9. {{1,2}, {3}, {4}}

10. {{1,3}, {2}, {4}}

11. {{1,4}, {2}, {3}}

12. {{2,3}, {1}, {4}}

13. {{2,4}},{1}, {3}}

14. {{3,4}, {1}, {2}}

𝑇ℎ𝑒 𝑡𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑤𝑎𝑦𝑠 𝑜𝑓 𝑝𝑙𝑎𝑐𝑖𝑛𝑔 𝑛 𝑑𝑖𝑠𝑡𝑖𝑛𝑔𝑢𝑖𝑠ℎ𝑎𝑏𝑙𝑒 𝑏𝑎𝑙𝑙𝑠 𝑖𝑛𝑡𝑜 𝑘 𝑖𝑛𝑑𝑖𝑠𝑡𝑖𝑛𝑔𝑢𝑖𝑠ℎ𝑎𝑏𝑙𝑒 𝑏𝑖𝑛𝑠:

∑ 𝑆(𝑛, 𝑗) = ∑1

𝑗!

𝑘𝑗=1 ∑ (−1)𝑖 (

𝑗𝑖) (𝑗 − 𝑖)𝑛

𝑗−1𝑖=0

𝑘𝑗=1 (12)

From (12), it can be seen that 𝑆(4,1) + 𝑆(4,2) + 𝑆(4,3) = 14

Placing indistinguishable balls into indistinguishable bins (II)

Consider the following problem: Express n as the sum of at most k positive integers

in a decreasing order. An expression:

∑ 𝑥𝑖 = 𝑛𝑗𝑖=1 , where 𝑥1 ≥ 𝑥2 ≥ 𝑥3 ≥ ⋯ ≥ 𝑥𝑗 = 𝑛,

where 𝑥𝑖 is a positive integer, is called a partition of n into j integers. Consequently, the

number of partitions of n integers into at most k positive integers is equal to the number of

ways of placing n indistinguishable balls into k indistinguishable bins. As is the case of

placing distinguishable balls into indistinguishable bins, unfortunately, there is no closed

form formula for counting the partitions. Given n = 6, the following are the partitions:

6 = 6

5 + 1 = 6

4 + 2 = 6

4 + 1 + 1 = 6

3 + 3 = 6

3 + 2 + 1 = 6

Page 27: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

17

3 + 1 + 1 + 1 = 6

2 + 2 + 2 = 6

2 + 2 + 1 + 1 = 6

2.5 COST METRIC

Given a set of algorithms that achieve the same goal, most often, the deciding factor

which places an algorithm on top of the list is the cost of the algorithm based on some cost

measure. It is fair to say that one of the most desirable properties for an algorithm which

generates combinatorial objects is the Constant Amortized Time (CAT) property.

CAT

The CAT property is based on the idea that the computational cost of an algorithm is

proportional to the size of the output of the algorithm. This means that the time to process

and output of the combinatorial objects is not considered. For example, given a

combinatorial algorithm L with input x and output of X objects (each of size x), then L has

the CAT property since its running time is O(X).

Page 28: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

18

CHAPTER 3

STATE OF THE ART

Combinations belong to the class of elementary combinatorial objects, so it comes

as no surprise that there are many algorithms for generating combinations. In spite of this,

a lot of these algorithms exhibit very similar properties such as the order of their tuples,

recursion (recursive or iterative), loop (loop or loopless), and memory property. In this

chapter, five algorithms are presented.

3.1 ALGORITHM 1

Consider Algorithm 1 [2] which generates all k-Combinations 𝑐𝑘…𝑐2𝑐1 of n

numbers:,0, 1, 2, … , 𝑛 − 1 in Lex order.

𝐺𝑖𝑣𝑒𝑛 𝑛 ≥ 𝑘 ≥ 0, 𝑎𝑛𝑑 𝑠𝑒𝑛𝑡𝑖𝑛𝑒𝑙 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠 𝑐𝑘+1 𝑎𝑛𝑑 𝑐𝑘+2 𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝐿() 𝐼𝑛𝑖𝑡𝑖𝑎𝑙𝑖𝑧𝑒(); 𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝐼𝑛𝑖𝑡𝑖𝑎𝑙𝑖𝑧𝑒()

𝒘𝒉𝒊𝒍𝒆 1 = 1 𝒇𝒐𝒓 𝑗 = 1 𝒕𝒐 𝑘 𝒅𝒐

𝑉𝑖𝑠𝑖𝑡 𝑐𝑘 …𝑐2𝑐1; 𝑐𝑗 = 𝑗 − 1;

𝑗 = 1; 𝒆𝒏𝒅𝒇𝒐𝒓

𝒘𝒉𝒊𝒍𝒆 𝑐𝑗 + 1 = 𝑐𝑗+1 𝑐𝑘+1 = 𝑛;

𝑐𝑗 = 𝑗 − 1; 𝑐𝑘+2 = 0;

𝑗 = 𝑗 + 1; 𝒆𝒏𝒅

𝒆𝒏𝒅𝒘𝒉𝒊𝒍𝒆 𝒊𝒇 𝑗 > 𝑘 𝒕𝒉𝒆𝒏 𝑻𝒆𝒓𝒎𝒊𝒏𝒂𝒕𝒆; 𝒆𝒏𝒅𝒊𝒇

𝑐𝑗 = 𝑐𝑗 + 1;

𝒆𝒏𝒅𝒘𝒉𝒊𝒍𝒆 𝒆𝒏𝒅

Fig.12 Algorithm 1, Generating All Combinations in Lex Order

Page 29: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

19

In addition, Algorithm 1 does not have the CAT property. Another algorithm which

generates combinations in Lex order is Algorithm 2 [8]. Algorithm 2 is based upon the

following recurrence relation (13):

(𝑛𝑘) =

{

1 ; 𝑛 = 0

(𝑛 − 10

) ; 𝑘 = 0

(𝑛 − 1𝑛 − 1

) ; 𝑘 = 𝑛

(𝑛 − 1𝑘

) + (𝑛 − 1𝑘 − 1

) ; 0 < 𝑘 < 𝑛

(13)

3.2 ALGORITHM 2

𝐺𝑖𝑣𝑒𝑛, 𝑗: ℕ,𝑚: ℕ, 𝑎𝑛𝑑 𝑖𝑛𝑖𝑡𝑖𝑎𝑙 𝑐𝑎𝑙𝑙 𝑡𝑜 𝑝𝑟𝑜𝑐𝑒𝑑𝑢𝑟𝑒 𝐶𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛(1, 0) 𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝐶𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛(𝑗,𝑚) 𝒊𝒇 𝑗 > 𝑛 𝒕𝒉𝒆𝒏 𝑉𝑖𝑠𝑖𝑡 𝑏1𝑏2𝑏3…𝑏𝑛; 𝒆𝒍𝒔𝒆 𝒊𝒇 𝑘 − 𝑚 < 𝑛 − 𝑗 + 1 𝒕𝒉𝒆𝒏 𝑏𝒋 = 0;

𝐶𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛(𝑗 + 1,𝑚); 𝒆𝒏𝒅𝒊𝒇 𝒊𝒇 𝑚 < 𝑘 𝒕𝒉𝒆𝒏 𝑏𝒋 = 1;

𝐶𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛(𝑗 + 1, 𝑚 + 1); 𝒆𝒏𝒅𝒊𝒇 𝒆𝒏𝒅𝒊𝒇 𝒆𝒏𝒅

Algorithm 2 just like algorithm 1 does not have the CAT property. However, Algorithm 2

is recursive – hence the simplicity. Also note that this algorithm generates combinations in

binary string format.

Fig.13 Algorithm 2, Generating All Combinations in Lex Order

Page 30: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

20

The algorithms explored so far generate combinations in Lex order. Consequently,

let us consider a recursive algorithm [3] which generates combinations in CoLex order.

Note that Algorithm 3 generates combinations in binary string format. Algorithm 3 is based

on the following recurrence relation (14):

𝑡(𝑛, 𝑘) = {

1 ; 𝑛 = 01 + 𝑡(𝑛 − 1, 0) ; 𝑘 = 0

1 + 𝑡(𝑛 − 1, 𝑛 − 1) ; 𝑘 = 𝑛

1 + 𝑡(𝑛 − 1, 𝑘) + 𝑡(𝑛 − 1, 𝑘 − 1) ; 0 < 𝑘 < 𝑛

3.3 ALGORITHM 3

Similar to the already explored algorithms, Algorithm 3 does not have the CAT property

since

𝑡(𝑛,𝑘)+1

(𝑛𝑘)

=(𝑛+2)(𝑛+1)

𝑘+1(𝑛−𝑘+1) (15)

𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝐶𝑜𝑙𝑒𝑥( 𝑛: ℕ, 𝑘: ℕ )

𝒊𝒇 𝑛 = 0 𝒕𝒉𝒆𝒏 𝑉𝑖𝑠𝑖𝑡 𝑏1𝑏2𝑏3…𝑏𝑛; 𝒆𝒍𝒔𝒆 𝒊𝒇 𝑘 < 𝑛 𝒕𝒉𝒆𝒏

𝑏𝑛 = 0; 𝐶𝑜𝑙𝑒𝑥( 𝑛 − 1, 𝑘 ); 𝒆𝒏𝒅𝒊𝒇 𝒊𝒇 𝑘 > 0 𝒕𝒉𝒆𝒏

𝑏𝑛 = 1; 𝐶𝑜𝑙𝑒𝑥( 𝑛 − 1, 𝑘 − 1 ); 𝒆𝒏𝒅𝒊𝒇 𝒆𝒏𝒅𝒊𝒇 𝒆𝒏𝒅

(14)

Fig.14 Algorithm 3, Generating Combinations in Colex Order

Page 31: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

21

The algorithms considered so far do not have the CAT property. Consequently,

Algorithm 4 [4] below has this property. Also note Algorithm 4 generates combinations in

minimal change or gray code order (successive binary strings differ by a constant number

of bits).

3.4 ALGORITHM 4

𝐺𝑖𝑣𝑒𝑛, 𝑛: ℕ, 𝑘: ℕ, 𝑎𝑛𝑑 𝑔1𝑔2𝑔3…𝑔𝑛

𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒(𝑛, 𝑘) 𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝐼𝑛𝑖𝑡𝑖𝑎𝑙𝑖𝑧𝑒()

𝐼𝑛𝑖𝑡𝑖𝑎𝑙𝑖𝑧𝑒(); 𝒇𝒐𝒓 𝑖 = 1 𝒕𝒐 𝑘 𝒅𝒐

𝑉𝑖𝑠𝑖𝑡 𝑔1𝑔2𝑔3…𝑔𝑛; 𝑔𝑖= 1;

𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒1(𝑛, 𝑘); 𝒆𝒏𝒅𝒇𝒐𝒓

𝒆𝒏𝒅 𝒇𝒐𝒓 𝑖 = 𝑘 + 1 𝒕𝒐 𝑛 𝒅𝒐

𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒1(𝑛, 𝑘) 𝑔𝑖= 0;

𝒊𝒇 𝑘 > 0 𝒂𝒏𝒅 𝑘 < 𝑛 𝒕𝒉𝒆𝒏 𝒆𝒏𝒅𝒇𝒐𝒓

𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒1(𝑛 − 1, 𝑘); 𝒆𝒏𝒅

𝒊𝒇 𝑘 = 1 𝒕𝒉𝒆𝒏 𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒2(𝑛, 𝑘)

𝑔𝑛= 1; 𝒊𝒇 𝑘 > 0 𝒂𝒏𝒅 𝑘 < 𝑛 𝒕𝒉𝒆𝒏

𝑔𝑛−1

= 0; 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒1(𝑛 − 1, 𝑘 − 1);

𝑉𝑖𝑠𝑖𝑡 𝑔1𝑔2𝑔3…𝑔𝑛; 𝒊𝒇 𝑘 = 1 𝒕𝒉𝒆𝒏

𝒆𝒍𝒔𝒆 𝑔𝑛−1

= 1;

𝑔𝑛= 1; 𝑔

𝑛= 0;

𝑔𝑘−1

= 0; 𝑉𝑖𝑠𝑖𝑡 𝑔1𝑔2𝑔3…𝑔𝑛;

𝑉𝑖𝑠𝑖𝑡 𝑔1𝑔2𝑔3…𝑔𝑛; 𝒆𝒍𝒔𝒆

𝒆𝒏𝒅𝒊𝒇 𝑔𝑘−1

= 1;

𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒2(𝑛 − 1, 𝑘 − 1); 𝑔

𝑛= 0;

𝒆𝒏𝒅𝒊𝒇 𝑉𝑖𝑠𝑖𝑡 𝑔1𝑔2𝑔3…𝑔𝑛; 𝒆𝒏𝒅 𝒆𝒏𝒅𝒊𝒇

𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒2(𝑛 − 1, 𝑘);

𝒆𝒏𝒅𝒊𝒇

𝒆𝒏𝒅

Fig.15 Algorithm 4, Generating Combinations in Gray Code Order

Page 32: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

22

3.5 ALGORITHM 5

Finally, let us consider the CAT “Revolving – door combinations” [5], which

generates all k-Combinations in Lexicographic order based on the following sequence:

(𝑐𝑘, −𝑐𝑘−1, 𝑐𝑘−2, … , (−1)𝑘−1𝑐1) (16)

𝐺𝑖𝑣𝑒𝑛 𝑛 ≥ 𝑘 ≥ 1, 𝑐1𝑐2𝑐3…𝑐𝑘 , 𝑠𝑒𝑛𝑡𝑖𝑛𝑒𝑙 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 𝑐𝑘+1, 𝑎𝑛𝑑 𝑔𝑙𝑜𝑏𝑎𝑙 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 𝑗. 𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝑅()

𝐼𝑛𝑖𝑡𝑖𝑎𝑙𝑖𝑧𝑒(); 𝒇𝒖𝒏𝒕𝒊𝒐𝒏 𝑅1()

𝒓𝒆𝒑𝒆𝒂𝒕 𝒊𝒇 𝑗 = 𝑘 𝒕𝒉𝒆𝒏 𝑉𝑖𝑠𝑖𝑡 𝑐𝑘 …𝑐2𝑐1; 𝒓𝒆𝒕𝒖𝒓𝒏 𝑓𝑎𝑙𝑠𝑒; 𝒖𝒏𝒕𝒊𝒍 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒() = 𝑓𝑎𝑙𝑠𝑒; 𝒆𝒏𝒅𝒊𝒇 𝒆𝒏𝒅 𝒊𝒇 𝑐𝑗 > 𝑗 𝒕𝒉𝒆𝒏

𝒑𝒓𝒐𝒄𝒆𝒅𝒖𝒓𝒆 𝐼𝑛𝑖𝑡𝑖𝑎𝑙𝑖𝑧𝑒() 𝑐𝑗 = 𝑐𝑗−1;

𝒇𝒐𝒓 𝑖 = 1 𝑡𝑜 𝑘 𝒅𝒐 𝑐𝑗−1 = 𝑗 − 1;

𝑐𝑖 = 𝑖; 𝒓𝒆𝒕𝒖𝒓𝒏 𝑡𝑟𝑢𝑒; 𝒆𝒏𝒅𝒇𝒐𝒓 𝒆𝒏𝒅𝒊𝒇

𝑐𝑘+1 = 𝑛; 𝑗 = 𝑗 + 1; 𝒆𝒏𝒅 𝒓𝒆𝒕𝒖𝒓𝒏 𝑅2(); 𝒇𝒖𝒏𝒕𝒊𝒐𝒏 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒() 𝒆𝒏𝒅 𝑗 = 1; 𝒇𝒖𝒏𝒕𝒊𝒐𝒏 𝑅2() 𝒊𝒇 𝑘 𝑖𝑠 𝑜𝑑𝑑 𝒕𝒉𝒆𝒏 𝒊𝒇 𝑗 = 𝑘 𝒕𝒉𝒆𝒏 𝒊𝒇 𝑐1 + 1 < 𝑐1 𝒕𝒉𝒆𝒏 𝒓𝒆𝒕𝒖𝒓𝒏 𝑓𝑎𝑙𝑠𝑒;

𝑐1 = 𝑐1 + 1; 𝒆𝒏𝒅𝒊𝒇 𝒓𝒆𝒕𝒖𝒓𝒏 𝑡𝑟𝑢𝑒; 𝒊𝒇 𝑐𝑗 + 1 < 𝑐𝑗+1 𝒕𝒉𝒆𝒏

𝒆𝒍𝒔𝒆 𝑐𝑗−1 = 𝑐𝑗;

𝒓𝒆𝒕𝒖𝒓𝒏 𝑅1(); 𝑐𝑗 = 𝑐𝑗 + 1;

𝒆𝒏𝒅𝒊𝒇 𝒓𝒆𝒕𝒖𝒓𝒏 𝑡𝑟𝑢𝑒; 𝒆𝒍𝒔𝒆 𝒆𝒏𝒅𝒊𝒇 𝒊𝒇 𝑐1 > 0 𝒕𝒉𝒆𝒏 𝑗 = 𝑗 + 1;

𝑐1 = 𝑐1 − 1; 𝒓𝒆𝒕𝒖𝒓𝒏 𝑅1(); 𝒓𝒆𝒕𝒖𝒓𝒏 𝑡𝑟𝑢𝑒; 𝒆𝒏𝒅 𝒆𝒍𝒔𝒆

𝒓𝒆𝒕𝒖𝒓𝒏 𝑅2(); 𝒆𝒏𝒅𝒊𝒇 𝒆𝒏𝒅𝒊𝒇 𝒆𝒏𝒅

Fig.16 Revolving Door Combinations in Gray Code Order

Page 33: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

23

Algorithm 1.0 2.0 3.0 4.0 5.0

1 2 3 ...111 111... 111... 2 1 0

1 2 4 ..1.11 11.1.. 1.11.. 3 2 0

1 3 4 ..11.1 1.11.. .111.. 3 2 1

2 3 4 ..111. .111.. 11.1.. 3 1 0

1 2 5 .1..11 11..1. 1..11. 4 3 0

1 3 5 .1.1.1 1.1.1. .1.11. 4 3 1

2 3 5 .1.11. .11.1. ..111. 4 3 2

1 4 5 .11..1 1..11. 1.1.1. 4 2 0

2 4 5 .11.1. .1.11. .11.1. 4 2 1

3 4 5 .111.. ..111. 11..1. 4 1 0

1 2 6 1...11 11...1 1...11 5 4 0

1 3 6 1..1.1 1.1..1 .1..11 5 4 1

2 3 6 1..11. .11..1 ..1.11 5 4 2

1 4 6 1.1..1 1..1.1 ...111 5 4 3

2 4 6 1.1.1. .1.1.1 1..1.1 5 3 0

3 4 6 1.11.. ..11.1 .1.1.1 5 3 1

1 5 6 11...1 1...11 ..11.1 5 3 2

2 5 6 11..1. .1..11 1.1..1 5 2 0

3 5 6 11.1.. ..1.11 .11..1 5 2 1

4 5 6 111... ...111 11...1 5 1 0

Fig.17 Combinations;(63)

There are many more algorithm which generate combinations such as Eades-

McKay algorithm [6] which generates combinations in gray code order, and a combinations

generating algorithm based on prefix shifts [9] which generates combinations in Cool-lex

order and [7]. However, these algorithms share a lot of properties in common such as the

order of their tuples (Lex, CoLex, Gray code, etc), as well as efficiency (CAT property).

So far the algorithms we have explored and many other combinations generating

algorithms are tied to a specific tuple order. This is because these algorithms generate

combinations directly. This direct generation of combinations need not be the case: the

(63)

Page 34: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

24

following work outlined in the subsequent chapters explores a different method of

generating combinations, an indirect method. The consequence of this is a flexible means

of generating combinations wherein the generator defines the order of tuples. There are

two main objects which support generating combinations indirectly, namely the parent

combinatorial method, as well as the indexing combinatorial method. Since the parent

combinatorial object contains a superset of combinatorial objects including combinations,

all which is required, is a means to generate the indices corresponding to the location of

combinations. This is where the indexing method comes into play. This research effort

defines two objects required to generate combinations indirectly as follows:

Parent Combinatorial Method 1 (M1): is a non-recursive CAT algorithm for generating

permutations with repetitions allowed. M1 serves as the parent method since it contains

different kinds of combinatorial objects including combinations. Refer to chapter 2, to

explore the location of combinations in M1.

Indexing Combinatorial Method (f): this method generates a pattern which can be

translated to indices corresponding to the location of combinations in M1.

Page 35: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

25

As outlined by Fig. 19, the parent combinatorial method (M1) contains other combinatorial

objects besides combinations. Hence, the indexing combinatorial method (f) is needed to

extract combinations from the parent method. This means that the indexing combinatorial

method has knowledge of the locations of combinations in the parent combinatorial

method.

(𝑛

𝑘) Combinations

Algorithm to generate

Combinations

combinations object 1

Other combinatorial objects

combinations object 2

M1

(𝑛

𝑘) Combinations f

Fig.18 Direct Method of Generating Combinations

Fig.19 Indirect Method of Generating Combinations

Page 36: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

26

CHAPTER 4

STUDY OF THE DERIVATION OF M1

Let us consider the following study leading to the derivation of M1 – a CAT non-

recursive method for generating permutations with repetitions allowed. The goal is to find

a pattern and translate the language of the pattern into a series of mathematical formulae.

To do this, let us consider sections from six-permutations with repetitions allowed for a set

𝑈 = {𝐴, 𝐵, 𝐶}. As seen in Fig. 20, all columns from 1-6 count from the smallest alphabet

to the largest alphabet but do this in different ways. Fig. 20 is color coded to emphasize the

trends in the pattern. For instance column 1 reaches the largest alphabet quickly because it

does not repeat (no consecutive alphabets are the same). When column 1 reaches the largest

alphabet, it starts the counting process all over again. Column 2 counts but repeats the

counting alphabet, so it reaches the largest alphabet less quick when compared to column

1. When column 2 reaches the largest alphabet, it restarts the counting process. Columns

3, 4, and 5 behave in a similar way, the difference being the number of consecutive

alphabets. The last column counts with repetition but does not restart the count process.

The trend remains that column 1 is the fastest to reach the largest alphabet, column 2 is the

second fastest and so on. Also column 1 does not have consecutive characters of the same

type, column 2 counts with 3 consecutive characters of the same type, column 3 – 9, column

4 – 27, column 5 – 81, column 6 – 243.

Page 37: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

27

Column 6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1

1 A A A A A A 38 A A B B A B 75 A A C C A C

2 A A A A A B 39 A A B B A C 76 A A C C B A

3 A A A A A C 40 A A B B B A 77 A A C C B B

4 A A A A B A 41 A A B B B B 78 A A C C B C

5 A A A A B B 42 A A B B B C 79 A A C C C A

6 A A A A B C 43 A A B B C A 80 A A C C C B

7 A A A A C A 44 A A B B C B 81 A A C C C C

8 A A A A C B 45 A A B B C C 82 A B A A A A

9 A A A A C C 46 A A B C A A 83 A B A A A B

10 A A A B A A 47 A A B C A B 84 A B A A A C

11 A A A B A B 48 A A B C A C 85 A B A A B A

12 A A A B A C 49 A A B C B A 86 A B A A B B

13 A A A B B A 50 A A B C B B 87 A B A A B C

14 A A A B B B 51 A A B C B C 88 A B A A C A

15 A A A B B C 52 A A B C C A 89 A B A A C B

16 A A A B C A 53 A A B C C B 90 A B A A C C

17 A A A B C B 54 A A B C C C 91 A B A B A A

18 A A A B C C 55 A A C A A A 92 A B A B A B

19 A A A C A A 56 A A C A A B 93 A B A B A C

20 A A A C A B 57 A A C A A C 94 A B A B B A

21 A A A C A C 58 A A C A B A 95 A B A B B B

22 A A A C B A 59 A A C A B B 96 A B A B B C

23 A A A C B B 60 A A C A B C 97 A B A B C A

24 A A A C B C 61 A A C A C A 98 A B A B C B

25 A A A C C A 62 A A C A C B 99 A B A B C C

26 A A A C C B 63 A A C A C C 100 A B A C A A

27 A A A C C C 64 A A C B A A 101 A B A C A B

28 A A B A A A 65 A A C B A B 102 A B A C A C

29 A A B A A B 66 A A C B A C 103 A B A C B A

30 A A B A A C 67 A A C B B A 104 A B A C B B

31 A A B A B A 68 A A C B B B 105 A B A C B C

32 A A B A B B 69 A A C B B C 106 A B A C C A

33 A A B A B C 70 A A C B C A 107 A B A C C B

34 A A B A C A 71 A A C B C B 108 A B A C C C

35 A A B A C B 72 A A C B C C 109 A B B A A A

36 A A B A C C 73 A A C C A A 110 A B B A A B

37 A A B B A A 74 A A C C A B 111 A B B A A C

Fig.20 Study of the Derivation of M1

Page 38: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

28

Fig.20 Continued

Column 6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1

370 B B B C A A 411 B C A A B C 452 B C B C A B

371 B B B C A B 412 B C A A C A 453 B C B C A C

372 B B B C A C 413 B C A A C B 454 B C B C B A

373 B B B C B A 414 B C A A C C 455 B C B C B B

374 B B B C B B 415 B C A B A A 456 B C B C B C

375 B B B C B C 416 B C A B A B 457 B C B C C A

376 B B B C C A 417 B C A B A C 458 B C B C C B

377 B B B C C B 418 B C A B B A 459 B C B C C C

378 B B B C C C 419 B C A B B B 460 B C C A A A

379 B B C A A A 420 B C A B B C 461 B C C A A B

380 B B C A A B 421 B C A B C A 462 B C C A A C

381 B B C A A C 422 B C A B C B 463 B C C A B A

382 B B C A B A 423 B C A B C C 464 B C C A B B

383 B B C A B B 424 B C A C A A 465 B C C A B C

384 B B C A B C 425 B C A C A B 466 B C C A C A

385 B B C A C A 426 B C A C A C 467 B C C A C B

386 B B C A C B 427 B C A C B A 468 B C C A C C

387 B B C A C C 428 B C A C B B 469 B C C B A A

388 B B C B A A 429 B C A C B C 470 B C C B A B

389 B B C B A B 430 B C A C C A 471 B C C B A C

390 B B C B A C 431 B C A C C B 472 B C C B B A

391 B B C B B A 432 B C A C C C 473 B C C B B B

392 B B C B B B 433 B C B A A A 474 B C C B B C

393 B B C B B C 434 B C B A A B 475 B C C B C A

394 B B C B C A 435 B C B A A C 476 B C C B C B

395 B B C B C B 436 B C B A B A 477 B C C B C C

396 B B C B C C 437 B C B A B B 478 B C C C A A

397 B B C C A A 438 B C B A B C 479 B C C C A B

398 B B C C A B 439 B C B A C A 480 B C C C A C

399 B B C C A C 440 B C B A C B 481 B C C C B A

400 B B C C B A 441 B C B A C C 482 B C C C B B

401 B B C C B B 442 B C B B A A 483 B C C C B C

402 B B C C B C 443 B C B B A B 484 B C C C C A

403 B B C C C A 444 B C B B A C 485 B C C C C B

404 B B C C C B 445 B C B B B A 486 B C C C C C

405 B B C C C C 446 B C B B B B 487 C A A A A A

406 B C A A A A 447 B C B B B C 488 C A A A A B

Page 39: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

29

Fig.20 Continued

Column 6 5 4 3 2 1 6 5 4 3 2 1 6 5 4 3 2 1

620 C B B C C B 661 C C A B B A 702 C C B C C C

621 C B B C C C 662 C C A B B B 703 C C C A A A

622 C B C A A A 663 C C A B B C 704 C C C A A B

623 C B C A A B 664 C C A B C A 705 C C C A A C

624 C B C A A C 665 C C A B C B 706 C C C A B A

625 C B C A B A 666 C C A B C C 707 C C C A B B

626 C B C A B B 667 C C A C A A 708 C C C A B C

627 C B C A B C 668 C C A C A B 709 C C C A C A

628 C B C A C A 669 C C A C A C 710 C C C A C B

629 C B C A C B 670 C C A C B A 711 C C C A C C

630 C B C A C C 671 C C A C B B 712 C C C B A A

631 C B C B A A 672 C C A C B C 713 C C C B A B

632 C B C B A B 673 C C A C C A 714 C C C B A C

633 C B C B A C 674 C C A C C B 715 C C C B B A

634 C B C B B A 675 C C A C C C 716 C C C B B B

635 C B C B B B 676 C C B A A A 717 C C C B B C

636 C B C B B C 677 C C B A A B 718 C C C B C A

637 C B C B C A 678 C C B A A C 719 C C C B C B

638 C B C B C B 679 C C B A B A 720 C C C B C C

639 C B C B C C 680 C C B A B B 721 C C C C A A

640 C B C C A A 681 C C B A B C 722 C C C C A B

641 C B C C A B 682 C C B A C A 723 C C C C A C

642 C B C C A C 683 C C B A C B 724 C C C C B A

643 C B C C B A 684 C C B A C C 725 C C C C B B

644 C B C C B B 685 C C B B A A 726 C C C C B C

645 C B C C B C 686 C C B B A B 727 C C C C C A

646 C B C C C A 687 C C B B A C 728 C C C C C B

647 C B C C C B 688 C C B B B A 729 C C C C C C

648 C B C C C C 689 C C B B B B

649 C C A A A A 690 C C B B B C

650 C C A A A B 691 C C B B C A

651 C C A A A C 692 C C B B C B

652 C C A A B A 693 C C B B C C

653 C C A A B B 694 C C B C A A

654 C C A A B C 695 C C B C A B

655 C C A A C A 696 C C B C A C

656 C C A A C B 697 C C B C B A

Page 40: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

30

Following extensive study of the pattern from multiple permutations from different sets led

to the derivation of M1.

Given M1, the following is a usage example: Generate six-permutations (repetition

allowed) from the set 𝑈 = {𝐴, 𝐵, 𝐶} 𝑜𝑟 𝑈 = {1, 2, 3} for i = 729. Note that M1 disregards

fractions.

𝐼𝑛 𝑜𝑟𝑑𝑒𝑟 𝑡𝑜 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒 𝑡ℎ𝑒 𝑟 − 𝑝𝑒𝑟𝑚𝑢𝑡𝑎𝑡𝑖𝑜𝑛𝑠 𝑜𝑓 𝑎 𝑠𝑒𝑡 𝑤𝑖𝑡ℎ 𝑟𝑒𝑝𝑒𝑡𝑖𝑡𝑖𝑜𝑛 𝑎𝑙𝑙𝑜𝑤𝑒𝑑, 𝑡ℎ𝑒 𝑓𝑜𝑙𝑙𝑜𝑤𝑖𝑛𝑔 𝑜𝑟𝑖𝑔𝑖𝑛𝑎𝑙 𝑚𝑒𝑡ℎ𝑜𝑑 𝑀1 𝑖𝑠 𝑑𝑒𝑓𝑖𝑛𝑒𝑑:

𝐺𝑖𝑣𝑒𝑛 𝑎 𝑠𝑒𝑡 𝑈 𝑤𝑖𝑡ℎ 𝑓𝑖𝑟𝑠𝑡 𝑡𝑒𝑟𝑚 𝐴, |𝑈| = 𝑛, 1 ≤ 𝑖 ≤ 𝑛𝑟

𝑔1(𝑖) 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑠 𝑡ℎ𝑒 𝑙𝑎𝑠𝑡 𝑡𝑒𝑟𝑚

𝑔2(𝑖) 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑠 𝑡ℎ𝑒 𝑠𝑒𝑐𝑜𝑛𝑑 𝑡𝑜 𝑙𝑎𝑠𝑡 𝑡𝑒𝑟𝑚

… 𝑔𝑗(𝑖) 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑒𝑠 𝑡ℎ𝑒 𝑓𝑖𝑟𝑠𝑡 𝑡𝑒𝑟𝑚

𝑓(𝑖) = {

𝑖

𝑛− 1, 𝑖 𝑚𝑜𝑑 𝑛 = 0

𝑖

𝑛, 𝑖 𝑚𝑜𝑑 𝑛 ≠ 0

𝑔1(𝑖) = 𝐴 + 𝑖 − 𝑛𝑓(𝑖) − 1

𝑔2(𝑖) = {𝐴 + 𝑓(𝑖), 𝑓(𝑖) < 𝑛

𝐴 + (𝑓(𝑖) 𝑚𝑜𝑑 𝑛), 𝑓(𝑖) ≥ 𝑛

𝑔3(𝑖) =

{

𝐴 , 𝑓(𝑖) < 𝑛

𝐴 +𝑓(𝑖)

𝑛 , 𝑛 ≤ 𝑓(𝑖) < 𝑛2

𝐴 + (𝑓(𝑖)

𝑛− 𝑛)𝑚𝑜𝑑 𝑛, 𝑓(𝑖) ≥ 𝑛2

𝑔𝑗(𝑖) = {

𝐴, 𝑓(𝑖) < 𝑛𝑗−2

𝐴 + ((𝑓(𝑖)

𝑛𝑗−2)𝑚𝑜𝑑 𝑛) , 𝑓(𝑖) ≥ 𝑛𝑗−2

Fig.21 Non-Recursive Method for Generating Permutations (Repetitions Allowed) – M1

Page 41: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

31

Solution: 𝑖 = 729, 𝑛 = 3, 𝐴 = 1

𝑓(729) =729

3− 1 = 242

𝑔1(729) = 1 + 729 − 3(242) − 1 = 3 𝑜𝑟 𝐶

𝑔2(729) = 1 + (242 𝑚𝑜𝑑 3) = 3 𝑜𝑟 𝐶

𝑔3(729) = 1 + ((242

3− 3) 𝑚𝑜𝑑 3) = 3 𝑜𝑟 𝐶

𝑔4(729) = 1 + ((242

34−2) 𝑚𝑜𝑑 3) = 3 𝑜𝑟 𝐶

𝑔5(729) = 1 + ((242

35−2) 𝑚𝑜𝑑 3) = 3 𝑜𝑟 𝐶

𝑔6(729) = 1 + ((242

36−2) 𝑚𝑜𝑑 3) = 3 𝑜𝑟 𝐶

4.1 PROPERTIES OF M1

M1 is non-recursive, loopless (finding the ith r-permutation does not involve a

loop), memoryless (can be started from anywhere given) and is of the CAT family because

given the ith permutation, the computation required to compute the (i+1)th permutation is

constant – involving a fix number of operations, without any looping. Another interesting

feature of M1 is the fact that in the listing of all the tuples of the r-permutations (repetition

allowed) of a set, M1 is capable of listing tuples in multiple order (e.g lex, reverse lex, etc).

Consequently, any indexing algorithm which generates integers (1 ≤ 𝑟 ≤ 𝑛𝑟) in a given

order O corresponding to the r-permutations of a set can be used to generate combinatorial

objects from M1 in order O. For example, if we generate integers (1 ≤ 𝑟 ≤ 𝑛𝑟) from

smallest to largest and index M1, the combinatorial objects resulting from such operation

will be in lexicographic order. If the integers are generated from largest to smallest and

Page 42: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

32

substituted into M1 in this order, the resulting combinatorial objects will be in reverse

lexicographic order.

Page 43: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

33

CHAPTER 5

STUDY TO FIND COMBINATIONS PATTERN IN M1

Following the derivation of a highly efficient non-recursive method for generating

permutation with repetitions allowed (M1) – the parent combinatorial method, we should

now focus of how we can extract combinations from M1. To do this, we start from the

problem of placing n indistinguishable balls (of the same kind), into k distinguishable bins

(ID-Variant 2). This approach is justified by the equivalence relation in chapter 4 which

outlines a bijection relationship between ID-Variant 2 and the combinations problem.

Premise for solution

Consider the following:

1. SB – Enumeration of Stars and Bars for the balls and bins problem

(ID-Variant 2)

2. M1 (given) – an iterative method of generating permutations with

repetitions allowed.

3. A mirror image upper triangular matrix - an upper-matrix which has

a diagonal that runs from the top right to the bottom left (unlike the

conventional top left to bottom right diagonal of an upper triangular

matrix).

The problem of placing balls into bins corresponds to indexing M1. Therefore, the

following study seeks to investigate the pattern generated by indexing M1 as it corresponds

to placing five balls into one, and then two, three, four, and finally five bins.

Case SB(5,2), M1(6,1):

Page 44: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

34

SB M1

|***** 1

*|**** 2

**|*** 3

***|** 4

****|* 5

*****| 6 Fig.22 SB and M1 Pattern for Placing Five Balls into Two Bins in Bar Position Notation (BPN)

Case SB(5,3), M1(6,2):

1,1 2,2 3,3 4,4 5,5 6,6

1,2 2,3 3,4 4,5 5,6

1,3 2,4 3,5 4,6 6,1

1,4 2,5 3,6 5,1 6,2

1,5 2,6 4,1 5,2 6,3

1,6 3,1 4,2 5,3 6,4

2,1 3,2 4,3 5,4 6,5 Fig.23 M1 Pattern for Placing Five Balls into Three Bins in BPN

Case SB(5,4), M1(6,3):

Page 45: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

35

1,1,1 2,2,2 3,3,3 4,4,4 5,5,5 6,6,6

1,1,2 2,2,3 3,3,4 4,4,5 5,5,6

1,1,3 2,2,4 3,3,5 4,4,6 5,6,1

1,1,4 2,2,5 3,3,6 4,5,1 5,6,2

1,1,5 2,2,6 3,4,1 4,5,2 5,6,3

1,1,6 2,3,1 3,4,2 4,5,3 5,6,4

1,2,1 2,3,2 3,4,3 4,5,4 5,6,5

1,2,2 2,3,3 3,4,4 4,5,5 5,6,6

1,2,3 2,3,4 3,4,5 4,5,6 6,1,1

1,2,4 2,3,5 3,4,6 4,6,1 6,1,2

1,2,5 2,3,6 3,5,1 4,6,2 6,1,3

1,2,6 2,4,1 3,5,2 4,6,3 6,1,4

1,3,1 2,4,2 3,5,3 4,6,4 6,1,5

1,3,2 2,4,3 3,5,4 4,6,5 6,1,6

1,3,3 2,4,4 3,5,5 4,6,6 6,2,1

1,3,4 2,4,5 3,5,6 5,1,1 6,2,2

1,3,5 2,4,6 3,6,1 5,1,2 6,2,3

1,3,6 2,5,1 3,6,2 5,1,3 6,2,4

1,4,1 2,5,2 3,6,3 5,1,4 6,2,5

1,4,2 2,5,3 3,6,4 5,1,5 6,2,6

1,4,3 2,5,4 3,6,5 5,1,6 6,3,1

1,4,4 2,5,5 3,6,6 5,2,1 6,3,2

1,4,5 2,5,6 4,1,1 5,2,2 6,3,3

1,4,6 2,6,1 4,1,2 5,2,3 6,3,4

1,5,1 2,6,2 4,1,3 5,2,4 6,3,5

1,5,2 2,6,3 4,1,4 5,2,5 6,3,6

1,5,3 2,6,4 4,1,5 5,2,6 6,4,1

1,5,4 2,6,5 4,1,6 5,3,1 6,4,2

1,5,5 2,6,6 4,2,1 5,3,2 6,4,3

1,5,6 3,1,1 4,2,2 5,3,3 6,4,4

1,6,1 3,1,2 4,2,3 5,3,4 6,4,5

1,6,2 3,1,3 4,2,4 5,3,5 6,4,6

1,6,3 3,1,4 4,2,5 5,3,6 6,5,1

1,6,4 3,1,5 4,2,6 5,4,1 6,5,2

1,6,5 3,1,6 4,3,1 5,4,2 6,5,3

1,6,6 3,2,1 4,3,2 5,4,3 6,5,4

2,1,1 3,2,2 4,3,3 5,4,4 6,5,5

2,1,2 3,2,3 4,3,4 5,4,5 6,5,6

2,1,3 3,2,4 4,3,5 5,4,6 6,6,1 Fig.24 M1 Pattern for Placing Five Balls into Four Bins in BPN

Page 46: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

36

Fig.24 Continued

Case SB(5,5), M1(6,4):

1,1,1,1 2,2,2,2 3,3,3,3 4,4,4,4 5,5,5,5 6,6,6,6

1,1,1,2 2,2,2,3 3,3,3,4 4,4,4,5 5,5,5,6

1,1,1,3 2,2,2,4 3,3,3,5 4,4,4,6 5,5,6,1

1,1,1,4 2,2,2,5 3,3,3,6 4,4,5,1 5,5,6,2

1,1,1,5 2,2,2,6 3,3,4,1 4,4,5,2 5,5,6,3

1,1,1,6 2,2,3,1 3,3,4,2 4,4,5,3 5,5,6,4

1,1,2,1 2,2,3,2 3,3,4,3 4,4,5,4 5,5,6,5

1,1,2,2 2,2,3,3 3,3,4,4 4,4,5,5 5,5,6,6

1,1,2,3 2,2,3,4 3,3,4,5 4,4,5,6 5,6,1,1

1,1,2,4 2,2,3,5 3,3,4,6 4,4,6,1 5,6,1,2

1,1,2,5 2,2,3,6 3,3,5,1 4,4,6,2 5,6,1,3

1,1,2,6 2,2,4,1 3,3,5,2 4,4,6,3 5,6,1,4

1,1,3,1 2,2,4,2 3,3,5,3 4,4,6,4 5,6,1,5

1,1,3,2 2,2,4,3 3,3,5,4 4,4,6,5 5,6,1,6

1,1,3,3 2,2,4,4 3,3,5,5 4,4,6,6 5,6,2,1

1,1,3,4 2,2,4,5 3,3,5,6 4,5,1,1 5,6,2,2

1,1,3,5 2,2,4,6 3,3,6,1 4,5,1,2 5,6,2,3

1,1,3,6 2,2,5,1 3,3,6,2 4,5,1,3 5,6,2,4

1,1,4,1 2,2,5,2 3,3,6,3 4,5,1,4 5,6,2,5

1,1,4,2 2,2,5,3 3,3,6,4 4,5,1,5 5,6,2,6

1,1,4,3 2,2,5,4 3,3,6,5 4,5,1,6 5,6,3,1

1,1,4,4 2,2,5,5 3,3,6,6 4,5,2,1 5,6,3,2

1,1,4,5 2,2,5,6 3,4,1,1 4,5,2,2 5,6,3,3

1,1,4,6 2,2,6,1 3,4,1,2 4,5,2,3 5,6,3,4

1,1,5,1 2,2,6,2 3,4,1,3 4,5,2,4 5,6,3,5

1,1,5,2 2,2,6,3 3,4,1,4 4,5,2,5 5,6,3,6

1,1,5,3 2,2,6,4 3,4,1,5 4,5,2,6 5,6,4,1

1,1,5,4 2,2,6,5 3,4,1,6 4,5,3,1 5,6,4,2

1,1,5,5 2,2,6,6 3,4,2,1 4,5,3,2 5,6,4,3

1,1,5,6 2,3,1,1 3,4,2,2 4,5,3,3 5,6,4,4 Fig.25 M1 Pattern for Placing Five Balls into Five Bins in BPN

2,1,4 3,2,5 4,3,6 5,5,1 6,6,2

2,1,5 3,2,6 4,4,1 5,5,2 6,6,3

2,1,6 3,3,1 4,4,2 5,5,3 6,6,4

2,2,1 3,3,2 4,4,3 5,5,4 6,6,5

Page 47: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

37

Fig.25 Continued

1,1,6,1 2,3,1,2 3,4,2,3 4,5,3,4 5,6,4,5

1,1,6,2 2,3,1,3 3,4,2,4 4,5,3,5 5,6,4,6

1,1,6,3 2,3,1,4 3,4,2,5 4,5,3,6 5,6,5,1

1,1,6,4 2,3,1,5 3,4,2,6 4,5,4,1 5,6,5,2

1,1,6,5 2,3,1,6 3,4,3,1 4,5,4,2 5,6,5,3

1,1,6,6 2,3,2,1 3,4,3,2 4,5,4,3 5,6,5,4

1,2,1,1 2,3,2,2 3,4,3,3 4,5,4,4 5,6,5,5

1,2,1,2 2,3,2,3 3,4,3,4 4,5,4,5 5,6,5,6

1,2,1,3 2,3,2,4 3,4,3,5 4,5,4,6 5,6,6,1

1,2,1,4 2,3,2,5 3,4,3,6 4,5,5,1 5,6,6,2

1,2,1,5 2,3,2,6 3,4,4,1 4,5,5,2 5,6,6,3

1,2,1,6 2,3,3,1 3,4,4,2 4,5,5,3 5,6,6,4

1,2,2,1 2,3,3,2 3,4,4,3 4,5,5,4 5,6,6,5

1,2,2,2 2,3,3,3 3,4,4,4 4,5,5,5 5,6,6,6

1,2,2,3 2,3,3,4 3,4,4,5 4,5,5,6 6,1,1,1

1,2,2,4 2,3,3,5 3,4,4,6 4,5,6,1 6,1,1,2

1,2,2,5 2,3,3,6 3,4,5,1 4,5,6,2 6,1,1,3

1,2,2,6 2,3,4,1 3,4,5,2 4,5,6,3 6,1,1,4

1,2,3,1 2,3,4,2 3,4,5,3 4,5,6,4 6,1,1,5

1,2,3,2 2,3,4,3 3,4,5,4 4,5,6,5 6,1,1,6

1,2,3,3 2,3,4,4 3,4,5,5 4,5,6,6 6,1,2,1

1,2,3,4 2,3,4,5 3,4,5,6 4,6,1,1 6,1,2,2

1,2,3,5 2,3,4,6 3,4,6,1 4,6,1,2 6,1,2,3

1,2,3,6 2,3,5,1 3,4,6,2 4,6,1,3 6,1,2,4

1,2,4,1 2,3,5,2 3,4,6,3 4,6,1,4 6,1,2,5

1,2,4,2 2,3,5,3 3,4,6,4 4,6,1,5 6,1,2,6

1,2,4,3 2,3,5,4 3,4,6,5 4,6,1,6 6,1,3,1

1,2,4,4 2,3,5,5 3,4,6,6 4,6,2,1 6,1,3,2

1,2,4,5 2,3,5,6 3,5,1,1 4,6,2,2 6,1,3,3

1,2,4,6 2,3,6,1 3,5,1,2 4,6,2,3 6,1,3,4

1,2,5,1 2,3,6,2 3,5,1,3 4,6,2,4 6,1,3,5

1,2,5,2 2,3,6,3 3,5,1,4 4,6,2,5 6,1,3,6

1,2,5,3 2,3,6,4 3,5,1,5 4,6,2,6 6,1,4,1

1,2,5,4 2,3,6,5 3,5,1,6 4,6,3,1 6,1,4,2

1,2,5,5 2,3,6,6 3,5,2,1 4,6,3,2 6,1,4,3

1,2,5,6 2,4,1,1 3,5,2,2 4,6,3,3 6,1,4,4

1,2,6,1 2,4,1,2 3,5,2,3 4,6,3,4 6,1,4,5

1,2,6,2 2,4,1,3 3,5,2,4 4,6,3,5 6,1,4,6

1,2,6,3 2,4,1,4 3,5,2,5 4,6,3,6 6,1,5,1

1,2,6,4 2,4,1,5 3,5,2,6 4,6,4,1 6,1,5,2

Page 48: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

38

Fig.25 Continued

1,2,6,5 2,4,1,6 3,5,3,1 4,6,4,2 6,1,5,3

1,2,6,6 2,4,2,1 3,5,3,2 4,6,4,3 6,1,5,4

1,3,1,1 2,4,2,2 3,5,3,3 4,6,4,4 6,1,5,5

1,3,1,2 2,4,2,3 3,5,3,4 4,6,4,5 6,1,5,6

1,3,1,3 2,4,2,4 3,5,3,5 4,6,4,6 6,1,6,1

1,3,1,4 2,4,2,5 3,5,3,6 4,6,5,1 6,1,6,2

1,3,1,5 2,4,2,6 3,5,4,1 4,6,5,2 6,1,6,3

1,3,1,6 2,4,3,1 3,5,4,2 4,6,5,3 6,1,6,4

1,3,2,1 2,4,3,2 3,5,4,3 4,6,5,4 6,1,6,5

1,3,2,2 2,4,3,3 3,5,4,4 4,6,5,5 6,1,6,6

1,3,2,3 2,4,3,4 3,5,4,5 4,6,5,6 6,2,1,1

1,3,2,4 2,4,3,5 3,5,4,6 4,6,6,1 6,2,1,2

1,3,2,5 2,4,3,6 3,5,5,1 4,6,6,2 6,2,1,3

1,3,2,6 2,4,4,1 3,5,5,2 4,6,6,3 6,2,1,4

1,3,3,1 2,4,4,2 3,5,5,3 4,6,6,4 6,2,1,5

1,3,3,2 2,4,4,3 3,5,5,4 4,6,6,5 6,2,1,6

1,3,3,3 2,4,4,4 3,5,5,5 4,6,6,6 6,2,2,1

1,3,3,4 2,4,4,5 3,5,5,6 5,1,1,1 6,2,2,2

1,3,3,5 2,4,4,6 3,5,6,1 5,1,1,2 6,2,2,3

1,3,3,6 2,4,5,1 3,5,6,2 5,1,1,3 6,2,2,4

1,3,4,1 2,4,5,2 3,5,6,3 5,1,1,4 6,2,2,5

1,3,4,2 2,4,5,3 3,5,6,4 5,1,1,5 6,2,2,6

1,3,4,3 2,4,5,4 3,5,6,5 5,1,1,6 6,2,3,1

1,3,4,4 2,4,5,5 3,5,6,6 5,1,2,1 6,2,3,2

1,3,4,5 2,4,5,6 3,6,1,1 5,1,2,2 6,2,3,3

1,3,4,6 2,4,6,1 3,6,1,2 5,1,2,3 6,2,3,4

1,3,5,1 2,4,6,2 3,6,1,3 5,1,2,4 6,2,3,5

1,3,5,2 2,4,6,3 3,6,1,4 5,1,2,5 6,2,3,6

1,3,5,3 2,4,6,4 3,6,1,5 5,1,2,6 6,2,4,1

1,3,5,4 2,4,6,5 3,6,1,6 5,1,3,1 6,2,4,2

1,3,5,5 2,4,6,6 3,6,2,1 5,1,3,2 6,2,4,3

1,3,5,6 2,5,1,1 3,6,2,2 5,1,3,3 6,2,4,4

1,3,6,1 2,5,1,2 3,6,2,3 5,1,3,4 6,2,4,5

1,3,6,2 2,5,1,3 3,6,2,4 5,1,3,5 6,2,4,6

1,3,6,3 2,5,1,4 3,6,2,5 5,1,3,6 6,2,5,1

1,3,6,4 2,5,1,5 3,6,2,6 5,1,4,1 6,2,5,2

1,3,6,5 2,5,1,6 3,6,3,1 5,1,4,2 6,2,5,3

1,3,6,6 2,5,2,1 3,6,3,2 5,1,4,3 6,2,5,4

1,4,1,1 2,5,2,2 3,6,3,3 5,1,4,4 6,2,5,5

1,4,1,2 2,5,2,3 3,6,3,4 5,1,4,5 6,2,5,6

Page 49: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

39

Fig.25 Continued

1,4,1,3 2,5,2,4 3,6,3,5 5,1,4,6 6,2,6,1

1,4,1,4 2,5,2,5 3,6,3,6 5,1,5,1 6,2,6,2

1,4,1,5 2,5,2,6 3,6,4,1 5,1,5,2 6,2,6,3

1,4,1,6 2,5,3,1 3,6,4,2 5,1,5,3 6,2,6,4

1,4,2,1 2,5,3,2 3,6,4,3 5,1,5,4 6,2,6,5

1,4,2,2 2,5,3,3 3,6,4,4 5,1,5,5 6,2,6,6

1,4,2,3 2,5,3,4 3,6,4,5 5,1,5,6 6,3,1,1

1,4,2,4 2,5,3,5 3,6,4,6 5,1,6,1 6,3,1,2

1,4,2,5 2,5,3,6 3,6,5,1 5,1,6,2 6,3,1,3

1,4,2,6 2,5,4,1 3,6,5,2 5,1,6,3 6,3,1,4

1,4,3,1 2,5,4,2 3,6,5,3 5,1,6,4 6,3,1,5

1,4,3,2 2,5,4,3 3,6,5,4 5,1,6,5 6,3,1,6

1,4,3,3 2,5,4,4 3,6,5,5 5,1,6,6 6,3,2,1

1,4,3,4 2,5,4,5 3,6,5,6 5,2,1,1 6,3,2,2

1,4,3,5 2,5,4,6 3,6,6,1 5,2,1,2 6,3,2,3

1,4,3,6 2,5,5,1 3,6,6,2 5,2,1,3 6,3,2,4

1,4,4,1 2,5,5,2 3,6,6,3 5,2,1,4 6,3,2,5

1,4,4,2 2,5,5,3 3,6,6,4 5,2,1,5 6,3,2,6

1,4,4,3 2,5,5,4 3,6,6,5 5,2,1,6 6,3,3,1

1,4,4,4 2,5,5,5 3,6,6,6 5,2,2,1 6,3,3,2

1,4,4,5 2,5,5,6 4,1,1,1 5,2,2,2 6,3,3,3

1,4,4,6 2,5,6,1 4,1,1,2 5,2,2,3 6,3,3,4

1,4,5,1 2,5,6,2 4,1,1,3 5,2,2,4 6,3,3,5

1,4,5,2 2,5,6,3 4,1,1,4 5,2,2,5 6,3,3,6

1,4,5,3 2,5,6,4 4,1,1,5 5,2,2,6 6,3,4,1

1,4,5,4 2,5,6,5 4,1,1,6 5,2,3,1 6,3,4,2

1,4,5,5 2,5,6,6 4,1,2,1 5,2,3,2 6,3,4,3

1,4,5,6 2,6,1,1 4,1,2,2 5,2,3,3 6,3,4,4

1,4,6,1 2,6,1,2 4,1,2,3 5,2,3,4 6,3,4,5

1,4,6,2 2,6,1,3 4,1,2,4 5,2,3,5 6,3,4,6

1,4,6,3 2,6,1,4 4,1,2,5 5,2,3,6 6,3,5,1

1,4,6,4 2,6,1,5 4,1,2,6 5,2,4,1 6,3,5,2

1,4,6,5 2,6,1,6 4,1,3,1 5,2,4,2 6,3,5,3

1,4,6,6 2,6,2,1 4,1,3,2 5,2,4,3 6,3,5,4

1,5,1,1 2,6,2,2 4,1,3,3 5,2,4,4 6,3,5,5

1,5,1,2 2,6,2,3 4,1,3,4 5,2,4,5 6,3,5,6

1,5,1,3 2,6,2,4 4,1,3,5 5,2,4,6 6,3,6,1

1,5,1,4 2,6,2,5 4,1,3,6 5,2,5,1 6,3,6,2

1,5,1,5 2,6,2,6 4,1,4,1 5,2,5,2 6,3,6,3

1,5,1,6 2,6,3,1 4,1,4,2 5,2,5,3 6,3,6,4

Page 50: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

40

Fig.25 Continued

1,5,2,1 2,6,3,2 4,1,4,3 5,2,5,4 6,3,6,5

1,5,2,2 2,6,3,3 4,1,4,4 5,2,5,5 6,3,6,6

1,5,2,3 2,6,3,4 4,1,4,5 5,2,5,6 6,4,1,1

1,5,2,4 2,6,3,5 4,1,4,6 5,2,6,1 6,4,1,2

1,5,2,5 2,6,3,6 4,1,5,1 5,2,6,2 6,4,1,3

1,5,2,6 2,6,4,1 4,1,5,2 5,2,6,3 6,4,1,4

1,5,3,1 2,6,4,2 4,1,5,3 5,2,6,4 6,4,1,5

1,5,3,2 2,6,4,3 4,1,5,4 5,2,6,5 6,4,1,6

1,5,3,3 2,6,4,4 4,1,5,5 5,2,6,6 6,4,2,1

1,5,3,4 2,6,4,5 4,1,5,6 5,3,1,1 6,4,2,2

1,5,3,5 2,6,4,6 4,1,6,1 5,3,1,2 6,4,2,3

1,5,3,6 2,6,5,1 4,1,6,2 5,3,1,3 6,4,2,4

1,5,4,1 2,6,5,2 4,1,6,3 5,3,1,4 6,4,2,5

1,5,4,2 2,6,5,3 4,1,6,4 5,3,1,5 6,4,2,6

1,5,4,3 2,6,5,4 4,1,6,5 5,3,1,6 6,4,3,1

1,5,4,4 2,6,5,5 4,1,6,6 5,3,2,1 6,4,3,2

1,5,4,5 2,6,5,6 4,2,1,1 5,3,2,2 6,4,3,3

1,5,4,6 2,6,6,1 4,2,1,2 5,3,2,3 6,4,3,4

1,5,5,1 2,6,6,2 4,2,1,3 5,3,2,4 6,4,3,5

1,5,5,2 2,6,6,3 4,2,1,4 5,3,2,5 6,4,3,6

1,5,5,3 2,6,6,4 4,2,1,5 5,3,2,6 6,4,4,1

1,5,5,4 2,6,6,5 4,2,1,6 5,3,3,1 6,4,4,2

1,5,5,5 2,6,6,6 4,2,2,1 5,3,3,2 6,4,4,3

1,5,5,6 3,1,1,1 4,2,2,2 5,3,3,3 6,4,4,4

1,5,6,1 3,1,1,2 4,2,2,3 5,3,3,4 6,4,4,5

1,5,6,2 3,1,1,3 4,2,2,4 5,3,3,5 6,4,4,6

1,5,6,3 3,1,1,4 4,2,2,5 5,3,3,6 6,4,5,1

1,5,6,4 3,1,1,5 4,2,2,6 5,3,4,1 6,4,5,2

1,5,6,5 3,1,1,6 4,2,3,1 5,3,4,2 6,4,5,3

1,5,6,6 3,1,2,1 4,2,3,2 5,3,4,3 6,4,5,4

1,6,1,1 3,1,2,2 4,2,3,3 5,3,4,4 6,4,5,5

1,6,1,2 3,1,2,3 4,2,3,4 5,3,4,5 6,4,5,6

1,6,1,3 3,1,2,4 4,2,3,5 5,3,4,6 6,4,6,1

1,6,1,4 3,1,2,5 4,2,3,6 5,3,5,1 6,4,6,2

1,6,1,5 3,1,2,6 4,2,4,1 5,3,5,2 6,4,6,3

1,6,1,6 3,1,3,1 4,2,4,2 5,3,5,3 6,4,6,4

1,6,2,1 3,1,3,2 4,2,4,3 5,3,5,4 6,4,6,5

1,6,2,2 3,1,3,3 4,2,4,4 5,3,5,5 6,4,6,6

1,6,2,3 3,1,3,4 4,2,4,5 5,3,5,6 6,5,1,1

1,6,2,4 3,1,3,5 4,2,4,6 5,3,6,1 6,5,1,2

Page 51: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

41

Fig.25 Continued

1,6,2,5 3,1,3,6 4,2,5,1 5,3,6,2 6,5,1,3

1,6,2,6 3,1,4,1 4,2,5,2 5,3,6,3 6,5,1,4

1,6,3,1 3,1,4,2 4,2,5,3 5,3,6,4 6,5,1,5

1,6,3,2 3,1,4,3 4,2,5,4 5,3,6,5 6,5,1,6

1,6,3,3 3,1,4,4 4,2,5,5 5,3,6,6 6,5,2,1

1,6,3,4 3,1,4,5 4,2,5,6 5,4,1,1 6,5,2,2

1,6,3,5 3,1,4,6 4,2,6,1 5,4,1,2 6,5,2,3

1,6,3,6 3,1,5,1 4,2,6,2 5,4,1,3 6,5,2,4

1,6,4,1 3,1,5,2 4,2,6,3 5,4,1,4 6,5,2,5

1,6,4,2 3,1,5,3 4,2,6,4 5,4,1,5 6,5,2,6

1,6,4,3 3,1,5,4 4,2,6,5 5,4,1,6 6,5,3,1

1,6,4,4 3,1,5,5 4,2,6,6 5,4,2,1 6,5,3,2

1,6,4,5 3,1,5,6 4,3,1,1 5,4,2,2 6,5,3,3

1,6,4,6 3,1,6,1 4,3,1,2 5,4,2,3 6,5,3,4

1,6,5,1 3,1,6,2 4,3,1,3 5,4,2,4 6,5,3,5

1,6,5,2 3,1,6,3 4,3,1,4 5,4,2,5 6,5,3,6

1,6,5,3 3,1,6,4 4,3,1,5 5,4,2,6 6,5,4,1

1,6,5,4 3,1,6,5 4,3,1,6 5,4,3,1 6,5,4,2

1,6,5,5 3,1,6,6 4,3,2,1 5,4,3,2 6,5,4,3

1,6,5,6 3,2,1,1 4,3,2,2 5,4,3,3 6,5,4,4

1,6,6,1 3,2,1,2 4,3,2,3 5,4,3,4 6,5,4,5

1,6,6,2 3,2,1,3 4,3,2,4 5,4,3,5 6,5,4,6

1,6,6,3 3,2,1,4 4,3,2,5 5,4,3,6 6,5,5,1

1,6,6,4 3,2,1,5 4,3,2,6 5,4,4,1 6,5,5,2

1,6,6,5 3,2,1,6 4,3,3,1 5,4,4,2 6,5,5,3

1,6,6,6 3,2,2,1 4,3,3,2 5,4,4,3 6,5,5,4

2,1,1,1 3,2,2,2 4,3,3,3 5,4,4,4 6,5,5,5

2,1,1,2 3,2,2,3 4,3,3,4 5,4,4,5 6,5,5,6

2,1,1,3 3,2,2,4 4,3,3,5 5,4,4,6 6,5,6,1

2,1,1,4 3,2,2,5 4,3,3,6 5,4,5,1 6,5,6,2

2,1,1,5 3,2,2,6 4,3,4,1 5,4,5,2 6,5,6,3

2,1,1,6 3,2,3,1 4,3,4,2 5,4,5,3 6,5,6,4

2,1,2,1 3,2,3,2 4,3,4,3 5,4,5,4 6,5,6,5

2,1,2,2 3,2,3,3 4,3,4,4 5,4,5,5 6,5,6,6

2,1,2,3 3,2,3,4 4,3,4,5 5,4,5,6 6,6,1,1

2,1,2,4 3,2,3,5 4,3,4,6 5,4,6,1 6,6,1,2

2,1,2,5 3,2,3,6 4,3,5,1 5,4,6,2 6,6,1,3

2,1,2,6 3,2,4,1 4,3,5,2 5,4,6,3 6,6,1,4

2,1,3,1 3,2,4,2 4,3,5,3 5,4,6,4 6,6,1,5

2,1,3,2 3,2,4,3 4,3,5,4 5,4,6,5 6,6,1,6

Page 52: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

42

Fig.25 Continued

2,1,3,3 3,2,4,4 4,3,5,5 5,4,6,6 6,6,2,1

2,1,3,4 3,2,4,5 4,3,5,6 5,5,1,1 6,6,2,2

2,1,3,5 3,2,4,6 4,3,6,1 5,5,1,2 6,6,2,3

2,1,3,6 3,2,5,1 4,3,6,2 5,5,1,3 6,6,2,4

2,1,4,1 3,2,5,2 4,3,6,3 5,5,1,4 6,6,2,5

2,1,4,2 3,2,5,3 4,3,6,4 5,5,1,5 6,6,2,6

2,1,4,3 3,2,5,4 4,3,6,5 5,5,1,6 6,6,3,1

2,1,4,4 3,2,5,5 4,3,6,6 5,5,2,1 6,6,3,2

2,1,4,5 3,2,5,6 4,4,1,1 5,5,2,2 6,6,3,3

2,1,4,6 3,2,6,1 4,4,1,2 5,5,2,3 6,6,3,4

2,1,5,1 3,2,6,2 4,4,1,3 5,5,2,4 6,6,3,5

2,1,5,2 3,2,6,3 4,4,1,4 5,5,2,5 6,6,3,6

2,1,5,3 3,2,6,4 4,4,1,5 5,5,2,6 6,6,4,1

2,1,5,4 3,2,6,5 4,4,1,6 5,5,3,1 6,6,4,2

2,1,5,5 3,2,6,6 4,4,2,1 5,5,3,2 6,6,4,3

2,1,5,6 3,3,1,1 4,4,2,2 5,5,3,3 6,6,4,4

2,1,6,1 3,3,1,2 4,4,2,3 5,5,3,4 6,6,4,5

2,1,6,2 3,3,1,3 4,4,2,4 5,5,3,5 6,6,4,6

2,1,6,3 3,3,1,4 4,4,2,5 5,5,3,6 6,6,5,1

2,1,6,4 3,3,1,5 4,4,2,6 5,5,4,1 6,6,5,2

2,1,6,5 3,3,1,6 4,4,3,1 5,5,4,2 6,6,5,3

2,1,6,6 3,3,2,1 4,4,3,2 5,5,4,3 6,6,5,4

2,2,1,1 3,3,2,2 4,4,3,3 5,5,4,4 6,6,5,5

2,2,1,2 3,3,2,3 4,4,3,4 5,5,4,5 6,6,5,6

2,2,1,3 3,3,2,4 4,4,3,5 5,5,4,6 6,6,6,1

2,2,1,4 3,3,2,5 4,4,3,6 5,5,5,1 6,6,6,2

2,2,1,5 3,3,2,6 4,4,4,1 5,5,5,2 6,6,6,3

2,2,1,6 3,3,3,1 4,4,4,2 5,5,5,3 6,6,6,4

2,2,2,1 3,3,3,2 4,4,4,3 5,5,5,4 6,6,6,5

As seen from the series of studies (Fig. 22-25), M1 repeats SB. This is because M1

“respects” order unlike SB. For example, the string “1, 1, 1, 2” and “1, 1, 2, 1” are

equivalent since they mean that three bars are in the first position and one bar is in the

second position. As a result of this repetitive way of stating the same configuration, a

method which seeks to extract SB from M1 must eliminate the repetition. Similarly, this

Page 53: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

43

method could simply index M1 in a regular manner according to the pattern seen in Fig.

25 which depends on the number of bins. From the series of studies, it is clear that with the

exception of case SB(5,2), M1(6,1), the manner to index M1 follows a “count down shape.”

For example, let us define an integer x as the cardinality of a mirror image of an upper-

triangular matrix, and b as an empty i by i matrix. Consider the following counting

operations due to counting the size of mirror image upper-triangular matrices where i = 6.

Case SB(5,3), M1(6,2):

6 (means there is only one mirror image upper-triangular matrix of size six in this case)

Case SB(5,4), M1(6,3):

6 5 4 3 2 1

Case SB(5,5), M1(6,4):

From our study, we can also see an interesting and well know kind of pattern – a

fractal. This is clear because the pattern is self-similar and the “count down shape” remains

the same. Based on this observation, we could conjecture that case SB(5,6), M1(6,5) is

made up of the following mirror image upper-triangular matrices:

Case SB(5,6), M1(6,5):

6 5 4 3 2 1

b 5 4 3 2 1

b b 4 3 2 1

b b b 3 2 1

b b b b 2 1

b b b b b 1

6 5 4 3 2 1 b b b b b b b b b b b b

b 5 4 3 2 1 b 5 4 3 2 1 b b b b b b

b b 4 3 2 1 b b 4 3 2 1 b b 4 3 2 1

b b b 3 2 1 b b b 3 2 1 b b b 3 2 1

b b b b 2 1 b b b b 2 1 b b b b 2 1

b b b b b 1 b b b b b 1 b b b b b 1

b b b b b b b b b b b b b b b b b b

Page 54: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

44

As seen from Case SB(5,3), M1(6,2) to Case SB(5,6), M1(6,5), the pattern generated by

indexing M1 with entries that correspond to the position of the bars in SB is a recursive

one which can be described by the following fractal rules (Fig. 26):

Given the problem of placing n indistinguishable balls into k distinguishable bins (ID-

Variant 2), the function, fractal f(n,k) is defined as follows:

𝐿𝑒𝑡 𝑎 𝑙𝑖𝑠𝑡 𝑏𝑒 𝑑𝑒𝑓𝑖𝑛𝑒𝑑 𝑎𝑠 𝑎 𝑠𝑒𝑡 𝑤ℎ𝑖𝑐ℎ 𝑝𝑒𝑟𝑚𝑖𝑡𝑠 𝑟𝑒𝑝𝑒𝑡𝑖𝑡𝑖𝑜𝑛. 𝐿𝑒𝑡 𝑎 𝑙𝑖𝑠𝑡 𝑜𝑓 𝑙𝑖𝑠𝑡𝑠, 𝐴 𝑏𝑒 𝑑𝑒𝑓𝑖𝑛𝑒𝑑 𝑎𝑠 𝑓𝑜𝑙𝑙𝑜𝑤𝑠: 𝐴 = {{𝑥}, {𝑥 − 1}, {𝑥 − 2}, … {2}, {1}} 𝒇𝒖𝒏𝒄𝒕𝒊𝒐𝒏 𝑓(𝑛: ℕ, 𝑘: ℕ ) 𝑥 = 𝑛 + 1; 𝐺𝑖𝑣𝑒𝑛 𝑎 𝑠𝑒𝑡 𝑆, 𝒇𝒖𝒏𝒄𝒕𝒊𝒐𝒏 𝑏(S)

𝑦 = 𝑘 − 1; 𝒓𝒆𝒕𝒖𝒓𝒏 ⋃ {𝑏}|𝑆|𝑖=1

𝒊𝒇 𝑦 = 1 𝒕𝒉𝒆𝒏 𝒆𝒏𝒅

𝑝 = {1, 2, 3, … , 𝑥}; 𝒆𝒏𝒅𝒊𝒇 𝒊𝒇 𝑦 = 2 𝒕𝒉𝒆𝒏

𝑝 = {𝑥}; 𝒆𝒏𝒅𝒊𝒇 𝒊𝒇 𝑦 = 3 𝒕𝒉𝒆𝒏

𝑝 = {𝑥, 𝑥 − 1, 𝑥 − 2,… , 1}; 𝒆𝒏𝒅𝒊𝒇 𝒊𝒇 𝑦 > 3 𝒕𝒉𝒆𝒏 𝒇𝒐𝒓 𝑖 = 1 𝒕𝒐 𝑦 − 3 𝒅𝒐

{𝑥} = {𝐴1, 𝐴2, 𝐴3, … , 𝐴𝑥}

{𝑥 − 1} = {𝑏(𝐴𝑥)𝑥, 𝐴2, 𝐴3, … , 𝐴𝑥}

{𝑥 − 2} = {𝑏(𝐴𝑥)𝑥, 𝑏(𝐴𝑥)𝑥−1, 𝐴3, … , 𝐴𝑥} … {1} = {𝑏(𝐴𝑥)𝑥, 𝑏(𝐴𝑥)𝑥−1, 𝑏(𝐴𝑥)𝑥−2, … , 𝐴𝑥}

𝐴 = {{𝑥}, {𝑥 − 1}, {𝑥 − 2}, … , {2}, {1}} 𝒆𝒏𝒅𝒇𝒐𝒓 𝒆𝒏𝒅𝒊𝒇 𝑝 = 𝐴1 ∪ 𝐴2 ∪ 𝐴3 ∪, … ,∪ 𝐴𝑥

𝒆𝒏𝒅

b b b b b b b b b b b b b b b b b b

b b b b b b b b b b b b b b b b b b

b b b 3 2 1 b b b b b b b b b b b b

b b b b 2 1 b b b b 2 1 b b b b b b

b b b b b 1 b b b b b 1 b b b b b 1

Fig.26 Algorithm f

Page 55: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

45

Usage of f

Example 1: Generate pattern using f when n = 5, k = 2

𝑥 = 6, 𝑦 = 1

𝑝 = {1, 2, 3, 4, 5, 6}

Example 2: Generate pattern using f when n = 5, k = 3

𝑥 = 6, 𝑦 = 2

𝑝 = {6}

Example 3: Generate pattern using f when n = 5, k = 4

𝑥 = 6, 𝑦 = 3

𝑝 = {6, 5, 4, 3, 2, 1}

Example 4: Generate pattern using f when n = 5, k = 5

𝑥 = 6, 𝑦 = 4

𝐴 = {{6}, {5}, {4}, {3}, {2}, {1}} 𝑰𝒕𝒆𝒓𝒂𝒕𝒊𝒐𝒏 𝟏:

{6} = {{6}, {5}, {4}, {3}, {2}, {1}} {5} = {{𝑏}, {5}, {4}, {3}, {2}, {1}} {4} = {{𝑏}, {𝑏}, {4}, {3}, {2}, {1}} {3} = {{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}} {2} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}} {1} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}}

𝐴 = { {{6}, {5}, {4}, {3}, {2}, {1}},

{{𝑏}, {5}, {4}, {3}, {2}, {1}},

{{𝑏}, {𝑏}, {4}, {3}, {2}, {1}},

{{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}},

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}},

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}}

{ 𝑝 = 𝐴

Example 5: Generate pattern using f when n = 5, y = 6

Page 56: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

46

𝑥 = 6, 𝑦 = 5

𝐴 = {{6}, {5}, {4}, {3}, {2}, {1}} 𝑰𝒕𝒆𝒓𝒂𝒕𝒊𝒐𝒏 𝟏:

{6} = {{6}, {5}, {4}, {3}, {2}, {1}} 𝐴 = { {{6}, {5}, {4}, {3}, {2}, {1}},

{5} = {{𝑏}, {5}, {4}, {3}, {2}, {1}} {{𝑏}, {5}, {4}, {3}, {2}, {1}},

{4} = {{𝑏}, {𝑏}, {4}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {4}, {3}, {2}, {1}},

{3} = {{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}},

{2} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}},

{1} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}} }

𝑰𝒕𝒆𝒓𝒂𝒕𝒊𝒐𝒏 𝟐: {6} = {{6}, {5}, {4}, {3}, {2}, {1}} {3} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {5}, {4}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {4}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}}

{5} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {2} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {5}, {4}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {4}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}}

{4} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {1} = {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {4}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}} {{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}}

Page 57: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

47

𝐴 = { {{6}, {5}, {4}, {3}, {2}, {1}}

{{𝑏}, {5}, {4}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {4}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}},

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {5}, {4}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {4}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}},

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {4}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}},

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {3}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}},

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {2}, {1}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}},

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}}

{{𝑏}, {𝑏}, {𝑏}, {𝑏}, {𝑏}, {1}}

{

𝑝 = 𝐴

Page 58: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

48

CHAPTER 6

TRANSLATION OF PATTERN TO ID-VARIANT 2 SOLUTION

From the usage of f examples in Chapter 5, the set of patterns p look nothing like

an enumerative solution to the problem of placing n indistinguishable balls into k

distinguishable bins (ID-Variant 2). This is because p is only the container which holds

objects that will be translated to integer values. The integer values are subsequently

substituted into M1 to derive the position of the bars post translation. This chapter presents

two ways of translating p. The first way is straightforward but expensive because every

blank object (b) is visited. The second method is an optimization of the first method. Let

us consider the following translation examples using translation method 1 to translate the

set of patterns generated in chapter 5 usage of f examples.

6.1 TRANSLATION METHOD 1

Given the set of patterns p for a given x, an element pi represents a “marked” pi by

pi upper triangular matrix within an x by x upper triangular matrix. The following examples

illustrate the translation.

Example 6: Translate pattern generated by f when n = 5, k = 2, 𝑝 = {1, 2, 3, 4, 5, 6}

Since y = 1, p requires no translation, thus can be substituted directly into M1 to derive the

position of the bars corresponding with placing five balls into two bins.

Example 7: Translate pattern generated by f when n = 5, k = 3, 𝑝 = {6}

Since x = 6 and p1 = 6, 6 × 6 of the 6 × 6 upper triangular matrix is marked (blue) yielding:

Page 59: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

49

Following translation, the set (Fig. 27) below can be substituted into M1 to get the position

of the bars corresponding to enumerating the configurations of placing five

indistinguishable balls into three distinguishable bins.

1 2 3 4 5 6 8 9 10 11 12 15 16 17 18 22 23 24 29 30 36

Fig.27 Translated Pattern for n = 5, y = 2

Example 8: Translate pattern generated by f when n = 5, k = 4, 𝑝 = {6, 5, 4, 3, 2, 1}

Since x = 6 and p1 = 6, 6 × 6 of the 6 × 6 upper triangular matrix is marked (blue) yielding:

p2 = 5, 5 × 5 of the 6 × 6 upper triangular matrix is marked (blue) yielding:

p3 = 4, 4 × 4 of the 6 × 6 upper triangular matrix is marked (blue) yielding:

b

b b

b b b

b b b b

b b b b b

1 2 3 4 5 6

7 8 9 10 11 12

13 14 15 16 17 18

19 20 21 22 23 24

25 26 27 28 29 30

31 32 33 43 35 36

b

b b

b b b

b b b b

b b b b b

1 2 3 4 5 6

7 8 9 10 11 12

13 14 15 16 17 18

19 20 21 22 23 24

25 26 27 28 29 30

31 32 33 43 35 36

b b b b b b

b

b b

b b b

b b b b

b b b b b

37 38 39 40 41 42

43 44 45 46 47 48

49 50 51 52 53 54

55 56 57 58 59 60

61 62 63 64 65 66

67 68 69 70 71 72

=

=

=

Page 60: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

50

p4 = 3, 3 × 3 of the 6 × 6 upper triangular matrix is marked (blue) yielding:

p5 = 2, 2 × 2 of the 6 × 6 upper triangular matrix is marked (blue) yielding:

p6= 1, 1 × 1 of the 6 × 6 upper triangular matrix is marked (blue) yielding:

b b b b b b

b b b b b b

b b

b b b

b b b b

b b b b b

73 74 75 76 77 78

79 80 81 82 83 84

85 86 87 88 89 90

91 92 93 94 95 96

97 98 99 100 101 102

103 104 105 106 107 108

b b b b b b

b b b b b b

b b b b b b

b b b

b b b b

b b b b b

109 110 111 112 113 114

115 116 117 118 119 120

121 122 123 124 125 126

127 128 129 130 131 132

133 134 135 136 137 138

139 140 141 142 143 144

b b b b b b

b b b b b b

b b b b b b

b b b b b b

b b b b

b b b b b

145 146 147 148 149 150

151 152 153 154 155 156

157 158 159 160 161 162

163 164 165 166 167 168

169 170 171 172 173 174

175 176 177 178 179 180

b b b b b b

b b b b b b

b b b b b b

b b b b b b

b b b b b b

b b b b b

181 182 183 184 185 186

187 188 189 190 191 192

193 194 195 196 197 198

199 200 201 202 203 204

205 206 207 208 209 210

211 212 213 214 215 216

=

=

=

=

Page 61: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

51

Following translation, the following set (Fig. 28) will be substituted into M1 to get the

position of the bars corresponding to enumerating the configurations of placing five

indistinguishable balls into four distinguishable bins.

1 2 3 4 5 6

8 9 10 11 12 15

16 17 18 22 23 24

29 30 36 44 45 46

47 48 51 52 53 54

58 59 60 65 66 72

87 88 89 90 94 95

96 101 102 108 130 131

132 137 138 144 173 174

180 216

Fig.28 Translation of Pattern When n = 5, k = 4

6.2 TRANSLATION METHOD 2

While translation method 1 is straightforward – involving a simple counting

operation, it is highly wasteful since it takes all the blanks into account. For this reason, it

visits more objects than needed. Translation method 2 solves this problem based on the

insight that all that is required to generate integer values, are the entry in the pattern set and

its position in the set. The following is the definition of translation method 2:

Given the set of patterns p for a given x, an element pi represents a two-dimensional array

A with pi rows and columns of length 𝑝𝑖, 𝑝𝑖 − 1, 𝑝𝑖 − 2,… , 1

For each pi , consider an offset parameter for 𝑖 ≠ 1

𝛿 = (𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑚𝑎𝑡𝑟𝑖𝑥 𝑝𝑜𝑠𝑖𝑡𝑖𝑜𝑛 × 𝑠𝑞𝑢𝑎𝑟𝑒 𝑚𝑎𝑡𝑟𝑖𝑥) + 𝑟𝑜𝑤𝑠 𝑜𝑓 𝑙𝑒𝑛𝑔𝑡ℎ 𝑥 + 𝑟𝑜𝑤𝑠 𝑜𝑓 𝑙𝑒𝑛𝑔𝑡ℎ 𝑙𝑒𝑠𝑠 𝑡ℎ𝑎𝑛 𝑥

𝛿 = (𝑖 − 1)𝑥2 + (𝑥 − 𝑝𝑖)𝑥 + (𝑥 − 𝑝𝑖)

For each pi , consider a set of offsets F, |𝐹| = 𝑝𝑖, 𝑝𝑖 ≠ 𝑥, 𝑝𝑖: ℤ, 𝑖 ≠ 1

Page 62: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

52

𝐹1 = 𝛿, 𝐹2 = 𝛿 + (𝑥 + 1), 𝐹3 = 𝛿 + 2(𝑥 + 1),…, 𝐹𝑝𝑖 = 𝛿 + (𝑝𝑖 − 1)(𝑥 + 1)

The translation rules are defined as follows:

𝒊𝒇 𝑝𝑖 = 𝑥 𝒕𝒉𝒆𝒏

A:

𝒆𝒍𝒔𝒆

A:

𝒆𝒏𝒅𝒊𝒇

Example 9: Translate pattern generated by f when n = 5, y = 4, 𝑝 = {6, 5, 4, 3, 2, 1} using

translation method 2.

𝑝1 = 6, 𝑖 = 1, 𝑥 = 6 A:

1 2 3 … 𝑥

2 + 𝑥 3 + 𝑥 … 𝑥 + 𝑥

3 + 2𝑥 … 𝑥 + 2𝑥

… 𝑥2

𝐹1 + 1 𝐹1 + 2 𝐹1 + 3 … 𝐹1 + 𝑝𝑖

𝐹2 + 1 𝐹2 + 2 … 𝐹2 + (𝑝𝑖 − 1)

𝐹3 + 1 … 𝐹3 + (𝑝𝑖 − 2)

𝐹𝑝𝑖 + 1

1 2 3 4 5 6

2 + 6 3 + 6 4 + 6 5 + 6 6 + 6

3 + 12 4 + 12 5 + 12 6 + 12

4 + 18 5 + 18 6 + 18

5 + 24 6 + 24

62

1 2 3 4 5 6

8 9 10 11 12

=

Page 63: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

53

𝑝2 = 5, 𝑖 = 2, 𝑥 = 6

𝛿 = 43 |𝐹| = 5

𝐹1 = 42 𝐹2 = 50

𝐹3 = 57

𝐹4 = 64

𝐹5 = 71 A:

𝑝3, 𝑝4, 𝑝5, 𝑎𝑛𝑑 𝑝6 all follow the same path.

6.3 SUBSTITUTION INTO M1

After the pattern has been translated, the integer values can then be substituted into

M1 to derive the position of the bars as it corresponds to placing n indistinguishable balls

into k distinguishable bins. For example Fig. 29 shows the substitution of the integer values

into M1 resulting from translating the pattern p when n = 5 and k = 4.

15 16 17 18

22 23 24

29 30

36

43 + 1 43 + 2 43 + 3 43 + 4 43 + 5

50 + 1 50 + 2 50 + 3 50 + 4

57 + 1 57 + 2 57 + 3

64 + 1 64 + 2

71 + 1

44 45 46 47 48

51 52 53 54

58 59 60

65 66

72

=

Page 64: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

54

i g3(i) g2(i) g1(i) SB - NOTATION

1 1 1 1 |||*****

2 1 1 2 ||*|****

3 1 1 3 ||**|***

4 1 1 4 ||***|**

5 1 1 5 ||****|*

6 1 1 6 ||*****|

8 1 2 2 |*||****

9 1 2 3 |*|*|***

10 1 2 4 |*|**|**

11 1 2 5 |*|***|*

12 1 2 6 |*|****|

15 1 3 3 |**||***

16 1 3 4 |**|*|**

17 1 3 5 |**|**|*

18 1 3 6 |**|***|

22 1 4 4 |***||**

23 1 4 5 |***|*|*

24 1 4 6 |***|**|

29 1 5 5 |****||*

30 1 5 6 |****|*|

36 1 6 6 |*****||

44 2 2 2 *|||****

45 2 2 3 *||*|***

46 2 2 4 *||**|**

47 2 2 5 *||***|*

48 2 2 6 *||****|

51 2 3 3 *|*||***

52 2 3 4 *|*|*|**

53 2 3 5 *|*|**|*

54 2 3 6 *|*|***|

58 2 4 4 *|**||**

59 2 4 5 *|**|*|*

60 2 4 6 *|**|**|

65 2 5 5 *|***||*

66 2 5 6 *|***|*|

72 2 6 6 *|****||

87 3 3 3 **|||*** Fig.29 Substitution into M1 Resulting from Translating p When n = 5 and k = 4

Page 65: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

55

Fig.29 Continued

88 3 3 4 **||*|**

89 3 3 5 **||**|*

90 3 3 6 **||***|

94 3 4 4 **|*||**

95 3 4 5 **|*|*|*

96 3 4 6 **|*|**|

101 3 5 5 **|**||*

102 3 5 6 **|**|*|

108 3 6 6 **|***||

130 4 4 4 ***|||**

131 4 4 5 ***||*|*

132 4 4 6 ***||**|

137 4 5 5 ***|*||*

138 4 5 6 ***|*|*|

144 4 6 6 ***|**||

173 5 5 5 ****|||*

174 5 5 6 ****||*|

180 5 6 6 ****|*||

216 6 6 6 *****|||

Page 66: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

56

CHAPTER 7

BIJECTION, COST ANALYSIS AND GENERATING COMBINATIONS WITH f

So far, we have focused on the solution of the combinations problem from the

perspective of placing n indistinguishable balls into k distinguishable bins (ID-Variant 2).

This chapter presents a justification of this approach by showing that the combinations

problem can be reduced to ID-Variant 2 due to (17) below:

𝐶𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛𝑠(𝑁, 𝑘) = 𝑆𝐵(𝑁 − (𝑘 + 1) + 1, 𝑘 + 1) (17)

7.1 BIJECTION BETWEEN ID-VARIANT 2 AND COMBINATIONS

Given SB(n,k) - the problem of placing n indistinguishable balls into k

distinguishable bins (also known as ID-Variant 2 in this text), and the combinations

problem, C(n,k). Since the combinations problem is solved due to a reduction (17) to

SB(n,k), show that equation (17) holds.

Solution

𝐺𝑖𝑣𝑒𝑛 𝑡ℎ𝑒 𝐶𝑜𝑚𝑏𝑖𝑛𝑎𝑡𝑖𝑜𝑛𝑠 𝑝𝑟𝑜𝑏𝑙𝑒𝑚 𝐶(𝑁, 𝑘) = (𝑁𝑘) 𝑖𝑡𝑒𝑚𝑠 (18)

𝐺𝑖𝑣𝑒𝑛 𝑆𝐵(𝑁, 𝑘) = (𝑁 + 𝑘 − 1𝑘 − 1

) 𝑖𝑡𝑒𝑚𝑠 (19)

𝐹𝑟𝑜𝑚 (17), 𝑙𝑒𝑡 𝑋 = 𝑁 − (𝑘 + 1) + 1 𝑎𝑛𝑑 𝑦 = 𝑘 + 1

𝐹𝑟𝑜𝑚 (19), 𝑆𝐵(𝑋, 𝑦) = (𝑋 + 𝑦 − 1𝑦 − 1

) = (𝑁 − (𝑘 + 1) + 1 + (𝑘 + 1) − 1

(𝑘 + 1) − 1) (20)

= (𝑁𝑘)

7.2 COST ANALYSIS

Page 67: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

57

The cost of generating combinations C, is defined as follow:

𝐶 = 𝑐𝑜𝑠𝑡 𝑜𝑓 𝑔𝑒𝑛𝑒𝑟𝑎𝑡𝑖𝑛𝑔 𝑝𝑎𝑡𝑡𝑒𝑟𝑛 𝑃𝑔 +

𝑐𝑜𝑠𝑡 𝑜𝑓 𝑡𝑟𝑎𝑣𝑒𝑟𝑠𝑖𝑛𝑔 𝑝𝑎𝑡𝑡𝑒𝑟𝑛 𝑃𝑣 +

𝑐𝑜𝑠𝑡 𝑜𝑓 𝑡𝑟𝑎𝑠𝑙𝑎𝑡𝑖𝑛𝑔 𝑝𝑎𝑡𝑡𝑒𝑟𝑛 𝑃𝑡 +

𝑐𝑜𝑠𝑡 𝑜𝑓 𝑠𝑢𝑏𝑠𝑡𝑖𝑡𝑢𝑡𝑖𝑛𝑔 𝑝𝑎𝑡𝑡𝑒𝑟𝑛 𝑖𝑛𝑡𝑜 𝑀1 𝑃𝑠 = 𝑃𝑔 + 𝑃𝑣 + 𝑃𝑡 + 𝑃𝑠 (21)

Given that f has four cases (case y = 1 to y > 3), there are four costs C1, C2, C3, and C4 for

each case, with C4 as the largest cost. Consequently, let us examine the costs associated

with generating combinations for each case:

Given (𝑛1), since the first case does not need translation or traversing,

𝐶1 = 𝑃𝑔 + 𝑃𝑣 + 𝑃𝑡 + 𝑃𝑠 = 𝑃𝑔 + 0 + 0 + 𝑃𝑠

Since 𝑃𝑔 = 𝑃𝑠 = 𝑛

𝐶1 = 𝑛 + 0 + 0 + 𝑛 = 2𝑛

Amortized cost: 2𝑛

(𝑛1)= 2

Given (𝑛2), since 𝑝 = {𝑥}

𝐶2 = 𝑃𝑔 + 𝑃𝑣 + 𝑃𝑡 + 𝑃𝑠 = 1 + 1 + (𝑛2) + (

𝑛2) = 2 + 2 (

𝑛2)

Note that 𝑃𝑣 depends on the size of the pattern and 𝑃𝑡 depends on the (𝑛𝑘)

Amortized cost: 2

(𝑛2)+2(𝑛2)

(𝑛2)

, since 𝑛 ≥ 2, by upper bounding, 2

(22)+ 2 = 4

Given (𝑛3), since 𝑝 = {𝑥, 𝑥 − 1, 𝑥 − 2,… ,1}

𝐶3 = 𝑃𝑔 + 𝑃𝑣 + 𝑃𝑡 + 𝑃𝑠 = (𝑛 + 𝑘 − 1) + (𝑛 + 𝑘 − 1) + (𝑛3) + (

𝑛3)

𝐶3 = (𝑛 + 3 − 1) + (𝑛 + 3 − 1) + 2 (𝑛3)

𝐶3 = 2(𝑛 − 2) + 2 (𝑛3)

Page 68: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

58

Amortized cost: 2(𝑛−2)

(𝑛3)+2(𝑛3)

(𝑛3)= 2(𝑛 − 2) ×

3!(𝑛−3)

𝑛(𝑛−1)(𝑛−2)(𝑛−3)!

Since 𝑛 ≥ 3, by upper bounding, 2 ×3!

3(2)+ 2 = 4

Given (𝑛𝑘) , 𝐶4 = 𝑃𝑔 + 𝑃𝑣 + 𝑃𝑡 + 𝑃𝑠 = 𝑃𝑔 + 𝑃𝑣 + (

𝑛𝑘) + (

𝑛𝑘)

On close examination of case four (y > 3) of f, it becomes clear that the most

straightforward implementation of the block inside the for-loop involves a count-down (x,

x-1, x-2, …, 1) which contains a counting up operation (1, 2, 3, …, x). Consequently,

𝐶4 = 𝑃𝑔 + 𝑃𝑣 + 𝑃𝑡 + 𝑃𝑠 = (𝑘 − 4)(𝑛 + 1)𝑛+1 + (𝑛 + 1)𝑘−4 + (

𝑛𝑘) + (

𝑛𝑘)

As a result of C4 , f is not CAT for the last case. The waste is clear because of the blanks

taken into consideration and the aggregating operations. Also, another problem with f is

the fact that it is not memoryless; it continuously “grows” the pattern, so this could lead to

memory problems. However, f is a naïve method developed with the intention of

correctness, not efficiency. And algorithm f verifies another way of generating

combinations – an indirect method.

Page 69: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

59

7.3 GENERATING COMBINATIONS WITH f

7C3 Lex Relex Arbitrary1 Arbitrary2

....111 111.... ...111. 11.1...

...1.11 11.1... 1.1..1. ..111..

...11.1 11..1.. ..1..11 .11..1.

...111. 11...1. 1..11.. .1...11

..1..11 11....1 1...1.1 1....11

..1.1.1 1.11... .1...11 ..11.1.

..1.11. 1.1.1.. 11...1. 1.1..1.

..11..1 1.1..1. .1..11. 1..11..

..11.1. 1.1...1 1..1.1. 1..1.1.

..111.. 1..11.. ..11..1 .1..1.1

.1...11 1..1.1. .1.11.. .11...1

.1..1.1 1..1..1 .11..1. 1.11...

.1..11. 1...11. 11.1... ..1.1.1

.1.1..1 1...1.1 ..1.1.1 .1..11.

.1.1.1. 1....11 ..1.11. ...111.

.1.11.. .111... ...11.1 1.1...1

.11...1 .11.1.. .111... 1...1.1

.11..1. .11..1. .1.1.1. 11..1..

.11.1.. .11...1 1..1..1 .1.11..

.111... .1.11.. 1...11. ..1.11.

1....11 .1.1.1. ...1.11 .1.1.1.

1...1.1 .1.1..1 ....111 ....111

1...11. .1..11. 11....1 ..11..1

1..1..1 .1..1.1 111.... .1.1..1

1..1.1. .1...11 .11.1.. ...1.11

1..11.. ..111.. 1.1...1 111....

1.1...1 ..11.1. ..111.. ...11.1

1.1..1. ..11..1 11..1.. 1..1..1

1.1.1.. ..1.11. .11...1 1...11.

1.11... ..1.1.1 .1..1.1 11....1

11....1 ..1..11 1....11 11...1.

11...1. ...111. 1.1.1.. 1.1.1..

11..1.. ...11.1 ..11.1. .111...

11.1... ...1.11 .1.1..1 ..1..11

111.... ....111 1.11... .11.1..

Fig.30 f Output for (73) in Four Different Orders

Page 70: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

60

CHAPTER 8

APPLICATIONS

8.1 ALGORITHM f FOR STEM CELL RESEARCH

Stem cells are cells with the peculiar property of possessing the ability to divide

into different cell types. In addition to this regenerative property [10], stem cells also divide

to replenish the supply of other cells which may be injured or worn out as a result of normal

wear and tear [15]. There are two possible outcomes of progeny cells from stem cell

division; the new cells could remain stem cells like their parent or the new cells could

become specialized cells such as muscle, brain, and red blood cells.

The main properties which distinguish stem cells from other kinds of cells are their

ability to renew through cell division even after long periods of dormancy. This property

of stem cells is the driving force for regenerative medicine [13], since it offers the

possibility of treating diseases such as type I diabetes [12], heart disease and other blood

disorders [11].

As a result of present research, it has been shown that there exist three different kinds of

stem cells, namely: embryonic stem cells, somatic or adult stem cells, and Induced

Pluripotent stem cells (IPSCs) [14].

Given the novelty of stem cell research, there are many questions surrounding stem

cells. However, a fundamental question which stands out is: What is, or what are the

regulatory factors that control stem cell proliferation and self-renewal?

The answer to these questions could have serious implications in stem cell research; as it

could enable scientist to grow embryonic and adult stem cells more efficiently in the

Page 71: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

61

laboratory. Consequently, answers to this question could advance cell-based therapies or

drug screening [16].

Given the substantial implications surrounding the benefits of stem cells as it relates

to regenerative medicine, many studies have been conducted to understand the dynamics

of stem cells. When stem cells divides, the surrounding population decreases by one stem

cell (type 0 division) or remains constant (type 1 division), or increases by one (type 2

division). In the quest to understand the dynamics of stem cells, one such school of thought

considers stem cells as indistinguishable balls (since stem cells are identical) and the three

types of divisions as distinguishable bins. Consequently, due to (11) we can count the

configurations resulting from placing n stem cells into k division types. However, knowing

the cardinality of the sample space is insufficient for modelling. This calls for a systematic

means of enumerating the configurations. Since stem cells are modelled stochastically,

Algorithm f could be employed to generate the configurations resulting from placing n balls

into k bins in ransom tuple order.

8.2 M1 FOR IMPLEMENTING LICENSE PLATE SERIAL FORMAT

M1 could be easily adapted to generate license plate serials with a specific format.

For example, consider the following North Carolina/Virginia license plate serial format:

ABC – 1234. This representation means the first three symbols are alphabetic characters

(A-Z) and the last 4 symbols are numeric characters (0-9). Consequently, this serial format

can be implemented with two instances of M1 methods for the two different sets (alphabets

and numbers).

Firstly, let us consider generating the list of prefixes consisting of the alphabets.

Given the set 𝑈 = {𝐴, 𝐵, 𝐶}, 𝑔3 generates the first character, 𝑔2 generates the second

Page 72: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

62

character and 𝑔1 generates that last character as seen in Fig. 31:

g3 g2 g1

1 A A A

2 A A B

3 A A C

4 A A D

5 A A E

6 A A F

7 A A G

8 A A H

9 A A I

10 A A J

11 A A K

12 A A L

13 A A M

14 A A N

15 A A O

16 A A P

17 A A Q

18 A A R

19 A A S

20 A A T

21 A A U

22 A A V

23 A A W

24 A A X

25 A A Y

26 A A Z

. . .

17576 Z Z Z

Fig.31 Prefixes of License Plate Serial Format

Secondly, let us consider generating the list of suffixes consisting of numbers.

Given the set 𝑈 = {0,1,2, 3, … ,9}, 𝑔4 generates the first character, 𝑔3 generates the second,

𝑔2 – third, 𝑔1 – last character as seen in the figure Fig. 32:

Page 73: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

63

g4 g3 g2 g1

1 0 0 0 0

2 0 0 0 1

3 0 0 0 2

4 0 0 0 3

5 0 0 0 4

6 0 0 0 5

7 0 0 0 6

8 0 0 0 7

9 0 0 0 8

10 0 0 0 9

11 0 0 1 0

12 0 0 1 1

13 0 0 1 2

14 0 0 1 3

15 0 0 1 4

16 0 0 1 5

17 0 0 1 6

18 0 0 1 7

19 0 0 1 8

20 0 0 1 9

21 0 0 2 0

22 0 0 2 1

23 0 0 2 2

24 0 0 2 3

25 0 0 2 4

26 0 0 2 5

. . . .

10000 9 9 9 9

Fig.32 Suffixes of License Plate Serial Format

Finally, we can get the resultant license plate serial format list by finding the

cartesian product of the list of prefixes and the list of suffixes as outlined Fig. 33:

Page 74: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

64

1 A A A 0 0 0 0

2 A A A 0 0 0 1

3 A A A 0 0 0 2

4 A A A 0 0 0 3

5 A A A 0 0 0 4

6 A A A 0 0 0 5

7 A A A 0 0 0 6

8 A A A 0 0 0 7

9 A A A 0 0 0 8

10 A A A 0 0 0 9

11 A A A 0 0 1 0

12 A A A 0 0 1 1

13 A A A 0 0 1 2

14 A A A 0 0 1 3

15 A A A 0 0 1 4

16 A A A 0 0 1 5

17 A A A 0 0 1 6

18 A A A 0 0 1 7

19 A A A 0 0 1 8

20 A A A 0 0 1 9

21 A A A 0 0 2 0

22 A A A 0 0 2 1

23 A A A 0 0 2 2

24 A A A 0 0 2 3

25 A A A 0 0 2 4

26 A A A 0 0 2 5

. . . . . . . .

10000 A A A 9 9 9 9

10001 B B B 0 0 0 0

10002 B B B 0 0 0 1

10003 B B B 0 0 0 2

10004 B B B 0 0 0 3

10005 B B B 0 0 0 4

10006 B B B 0 0 0 5

10007 B B B 0 0 0 6

10008 B B B 0 0 0 7

10009 B B B 0 0 0 8

10010 B B B 0 0 0 9

. . . . . . . .

175760000 Z Z Z 9 9 9 9

Fig.33 List of License Plate Serials

Page 75: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

65

CHAPTER 9

CONCLUSION

Combinatorics remains a crucial area of mathematics which shows up in many

forms. And combinatorial solutions take the form of many counting methods such as

enumerating permutations and combinations. This research effort contributes a new

perspective of looking at and generating combinatorial objects – as objects belonging to a

parent combinatorial objects, and as a result can be harvested by indexing. This results in

a flexible means of arranging tuples. This idea is presented through the perspective of

generating combinations, but could be applied to other combinatorial objects such as

permutations and multisets. The solution definition comes in the form of two original

methods M1 – the parent combinatorial method and Algorithm f – the indexing

combinatorial method.

Through an empirical study, it is shown that M1, (a non-recursive method for

generating permutations with repetitions allowed) contains the position of bars

corresponding to the placement of n indistinguishable balls into k indistinguishable bins

(ID-Variant 2). The study also shows that the position of bars take the shape of a “count-

down” fractal. Thus leading to the development of Algorithm f.

Algorithm f, a naïve counting fractal concluded the study by generating a pattern

corresponding to the position of bars, which subsequently are translated to integer values

that are substituted to yield combinations. Even though, f proved to be wasteful, f is

sufficient to verify the indirect means of generating combinations. This was the ultimate

goal (correctness) not efficiency. However, a more efficient version of f could be possible.

Page 76: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

66

Notwithstanding, given the importance of the field of combinatorics, the results

from this research effort offer a new perspective, a perspective which could open new ways

of studying and generating combinatorial object.

Page 77: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

67

REFERENCES

[1] W. Feller, in An Introduction to Probability Theory and Its Applications, New

York, John Wiley & Sons, 1964.

[2] D. Knuth, The Art of Programming, Generation all Combinations, Addison-Wiley,

2005, p. 4.

[3] F. Ruskey, "Combinatorial Generation," in Combinatorial Generation, 2003, p. 60.

[4] F. Ruskey, "Combinatorial Generation," in Combinatorial Generation, 2003, p.

128.

[5] D. Knuth, in The Art of Programming, Generation all Combinations, Addison-

Wiley, 2005, p. 9.

[6] P. Eades and B. McKay, An Algorithm for generating subsets of fixed size with a

strong minimal change property, vol. 19, 1984, pp. 131-133.

[7] J. Gersting, Mathematical Structures for Computer Science, 7, Ed., Freeman, 2014,

p. 285.

[8] F. Ruskey, 1 10 2003. [Online]. Available:

http://www.1stworks.com/ref/RuskeyCombGen.pdf.

[9] F. Ruskey and W. Aaron, "The Coolest Way to Generate Combinations," Discrete

Mathematics, vol. 309, no. 17, 2009.

[10] "National Institute of Health," 28 April 2002. [Online]. Available:

http://stemcells.nih.gov/info/basics/pages/basics1.aspx.

[11] "Learn.Genetics," 2014. [Online]. Available:

http://learn.genetics.utah.edu/content/stemcells/sctoday/.

[12] "California Institute for Regenerative Medicine," 2013. [Online]. Available:

http://www.cirm.ca.gov/our-progress/type-1-diabetes-fact-sheet.

[13] "National Institute of Health," 9 December 2011. [Online]. Available:

http://stemcells.nih.gov/info/scireport/Pages/2006report.aspx.

[14] "New York Stem Cell Foundation," [Online]. Available:

http://www.nyscf.org/about-stem-cells/stem-cells-101.

Page 78: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

68

[15] "University of Rochester Medical Center," 2009. [Online]. Available:

http://www.urmc.rochester.edu/MediaLibraries/URMCMedia/life-sciences-

learning-center/documents/STUDENTStemCells10-8-09.pdf.

[16] "California Institute for Regenerative Medicine," 2013. [Online]. Available:

http://www.cirm.ca.gov/our-progress/stem-cells-therapies.

SUPPLEMENTAL SOURCES CONSULTED

[17] A. Nijenhuis and H. Wilf, Combinatorial algorithms for computers and calculators,

2 2 ed., New York: Academic Press, 1978.

[18] “National Academy of Sciences,” 2014. [Online]. Available:

http://www.nasonline.org/.

[19] “National Academy of Science,” 2014.[Online]. Available:

http://nas-sites.org/stemcells/

[20] K. Rosen, in Discrete Mathematics and Its Applications, 7 ed., New York:

McGMcGraw-Hill, 2012.

[21] T. Feil, J. Krone, in Essential Discrete Mathematics for Computer Science, New

Jerse New Jersey: Prentice Hall, 2002.

[22] G. Martin, in Counting: The Art of Enumerative Combinatorics, New York:

Springer-Verlag, 2001.

Page 79: GENERATING COMBINATORIAL OBJECTS A NEW ...anwala/files/Thesis_Nwala7.pdfGENERATING COMBINATORIAL OBJECTS – A NEW PERSPECTIVE by Alexander Chizoma Nwala B.Sc. December 2011, Elizabeth

69

VITA

Alexander Chizoma Nwala

Department of Computer Science

Old Dominion University

Norfolk, VA 23529

EDUCATION

M.S., 2014, Computer Science, Old Dominion University

B.S., 2011, Computer Science, Elizabeth City State University, Elizabeth City,

North Carolina

CONFERENCES/PUBLICATION & PRESENTATIONS/SUBMITTED PAPERS

Teaching Information Security with Workflow Technology – A Case Study

Approach, submitted to Journal of Information Systems Education

Persistence: Identical Object Disambiguation, Tracking and Tagging Algorithm

PathOrigin: Robust Noise Tolerant Path Comparison Algorithm

Department of Homeland Security University Network Summit – Poster Presenter

(2011), Washington DC, Presented “Non-Recursive Mathematical Implementation

of the Probability Tree Diagram: Part I,” Proceeding published in Catastrophes &

Complex Systems: Transportation, Student Day Abstract Book March 29, 2011

Department of Homeland Security University Network Summit (2008), Anaheim

California

WORKING/INTERNSHIP EXPERIENCE

Research Assistant, Old Dominion University (May 2012 – Present)

North Carolina Department of Transportation - Summer Intern (2009/2010/2011)

Department of General Education ECSU - Tutor (Spring 2009 – Fall 2011)

Typset using Word.