SlideShare a Scribd company logo
1 of 6
Download to read offline
A Formal Model and an Algorithm for Generating
the Permutations of a Multiset
VINCENZO DE FLORIO and GEERT DECONINCK
Electrical Engineering Department – ESAT
Katholieke Universiteit Leuven,
Kasteelpark Arenberg 10, 3001 Leuven-Heverlee
BELGIUM
Abstract: – This paper may be considered as a mathematical divertissement as well as a didactical tool for
undergraduate students in a universitary course on algorithms and computation. The well-known problem of
generating the permutations of a multiset of marks is considered. We define a formal model and an abstract
machine (an extended Turing machine). Then we write an algorithm to compute on that machine the successor
of a given permutation in the lexicographically ordered set of permutations of a multiset. Within the model we
analyze the algorithm, prove its correctness, and show that the algorithm solves the above problem. Then we
describe a slight modification of the algorithm and we analyze in which cases it may result in an improvement of
execution times.
Key-Words: – Computational combinatorics, permutations, Turing machines, algorithms, number theory.

1

Introduction

{0, 1, . . . , n − 1}. Let furthermore m be an integer,
0 < m ≤ n.

The problem of generating the permutations of a multiset of marks is considered. First some mathematical entities and properties are defined within a formal
model. Then an abstract machine is introduced and an
algorithm is shown which computes those entities on
the abstract machine. Within this framework the algorithm is analyzed and proved to be correct. Finally it
is shown that the algorithm computes the successor of
a given permutation in the ordered set of lexicographically ordered permutations.
The structure of this work is as follows: the formal
model, the machine and the algorithm are described
in Section 2. Section 3 deals with the link between
the algorithm and the process of generating the permutations of a multiset in lexicographical order. Some
conclusions are drawn in Section 4.

2
2.1

Definition 1 Set A = {a0 , a1 , . . . , am−1 } be called
“the Alphabet”.
Let Im = {0, 1, . . . , m − 1}. Let us consider multiset
M = {a0 , . . . , a0 , a1 , . . . , a1 , · · · , am−1 , . . . , am−1 }
c0

such that

i∈Im ci

c1

cm−1

= n and ∀i ∈ Im : ci > 0.

Definition 2 Any ordered arrangement of the elements of a multiset M be called M -permutation and
represented as pM or, where M is evident from the
context, as p. Let pM [i] (or p[i]) denote the (i + 1)th
element of p. Let us call P M (or simply P when unambiguous) the set of the M -permutations.

A machine and an algorithm

Let o : An → In be a bijection defined so that
∀i ∈ In : o(ai ) = i. Clearly o induces a total order on
the marks (and, a fortiori, on the elements of the Alphabet). Furthermore, through o, any M -permutation
may be interpreted as an n-digit, base-m number [1].

Prologue—some definitions

Let n be an integer, n > 2, and let An =
{a0 , a1 , . . . , an−1 } be a set of “marks”. Let In be set
1
2.2

Definition 3 Given multiset M as above, arrangement

Let us consider M, a generalized Turing machine [6]
with two tapes, T1 and T2 , and three heads, H1l , H1r ,
and H2 . Heads H1l and H1r are “jointed”, i.e., capable of reading or writing any two consecutive squares
of T1 at a time. H2 operates on T2 . Let us call S1 and
S2 resp. the set of squares of T1 and the set of squares
of T2 .

a0 · · · · · a0 · a1 · · · · · a1 · · · am−1 · · · · · am−1
c0

c1

A machine

cm−1

is called the zero permutation of M , or briefly its zero,
and is denoted as pM or simply as p0 when this can be
0
done unambiguously. For the sake of brevity, operator
“·”, concatenating any two marks, will be omitted in
the following.

Definition 7 Be s a square; square s then represents
the square which immediately follows s. For any t ∈ N
t

Definition 4 Given multiset M as above, arrangement

let s

cm−2

represent square ((. . . ( s ) . . . ) .

Definition 8 Let z1 ∈ S1 .
such that

 π1 (s) = 0


 π1 (s) = t






∀s ∈ S1 :

 π1 (s) = −t









am−1 . . . am−1 am−2 . . . am−2 · · · a0 . . . a0
cm−1

...

c0

is called the last permutation of M and is denoted as
pM .
∞
Definition 5 Given any two M -permutations, p1 and
p2 :
• p1 is said to be equal to p2 iff ∀i ∈ In : p1 [i] =
p2 [i]. Let p1 = p2 represent this property.

t

t

Bijection π1 : S1 → Z,
if s = z1 ,
if s = z1 and ∃t ∈ N
t

(s = z1 . . . ),
if s = z1 and ∃t ∈ N
t

(z1 = s

...

),

is called the relative distance from z1 in S1 . Following
the same procedure, let π2 : S2 → Z be the relative
distance from a fixed z2 ∈ S2 .

• p1 and p2 are said to be different iff ¬(p1 = p2 ),
or p1 = p2 for brevity.

From Def. 2, any M -permutation p can be coded on
Tape T1 of M by writing, ∀i ∈ In , mark p[i] onto

• p1 < p2 iff ∃k ∈ In
(∀j < k : p1 [j] =
p2 [j]) ∧ (p1 [k] < p2 [k]).

i

Theorem 1 For any M , pM is the only possible INF∞
permutation.

−1
square π1 (i), i.e., onto square z1 . . . .
Machine M can execute read, write and headmovement actions. These basic actions can be described via the following symbolic notation:
Let i be an integer and Hx and Hy be heads respectively operating on Tape Tx and Tape Ty (possibly the
same). Let sx be the square under Head Hx and sy the
square under Hy . Let us call πx and πy the relative
distances respectively for Tx and Ty (possibly equal).
Let r be a function converting a square into the mark
currently coded onto that square. Then let:

P ROOF By construction, pM is INF. Ab absurdo, let us
∞
suppose there exists a permutation p = pM which is
∞
INF. Then either p < pM or vice-versa. In both cases
∞
we reach a contradiction by Def. 5.
.

(Hx ) represent the output of a read of square sx ,
available as o(r(sx )) ∈ Im , and let
Hx represent the position of Head Hx ,
available as πx (sx ) ∈ Z.

Definition 6 Let p ∈ P M . An inversion is a couple of contiguous marks of p, p[i] and p[i + 1], i ∈
{0, . . . , n − 2}, such that p[i] < p[i + 1]. If no such
couple can be found in p, then p is said to be inversionfree (INF). If at least one such couple does exist, then
p is said to be non-inversion-free (NIF).

2
exists a symbolic assembler such that it is possible
to define symbolic constants by means of the pseudoinstruction DEFINE. Comments are also supported—
string “//” denotes the beginning of a comment which
continues up to the end of the line.
Finally, let us suppose that each of the above instructions, including each evaluation of a Boolean or arithmetical atom, lasts the same amount of time.

The infix, “overloaded” (in the sense of [5]) operator
“←” be used to represent both writings of squares and
absolute movements of heads as described below:
(Hx ) ← i

writes in sx mark o−1 (i mod n),

(Hx ) ← (Hy )
in sy ,

overwrites sx with the mark written

(Hx )
←
Hy
overwrites sx with mark
−1 (π (s ) mod n),
o
y y
Hx ← i

2.3

−1
moves Head Hx over square πx (i),

Hx

By means of the above just sketched agreements it is
possible to compose the following computational procedure:

← (Hy )
moves Head Hx over square
−1
πx (o(r(sy ))),

Hx

An algorithm for machine M

← Hy
moves Head Hx over square
−1
πx (πy (sy )).

proc SUCC
DEFINE NIF := 0
DEFINE INF := 1
do

Postfix operators “ ++ ” and “ -- ”, borrowed from the
grammar of the C programming language [2], are used
to represent incremental / decremental writings and
relative, single-square movements as follows:

// pM has found to be NIF.
// pM has found to be INF.

// Phase 1: Heads H1l and H1r are moved on the
// last couple of squares of the encoding of pM onto Tape 1.
// H1r is on the last such square, H1l on the last but one.

(Hx ) ++ increments, modulo n, the number coded
in the square under Head Hx , i.e., ∀i ∈
{0, . . . , n − 2}, mark ai is promoted to mark
ai+1 , and mark an−1 is demoted to mark a0 .

H1r ← n − 1
while (H1l ) ≥ (H1r ) ∧ H1l ≥ 0
do
H1r -H2 ← (H1r )
(H2 ) ++
od

(Hx ) -- decrements, modulo n, the number coded
in the square under Head Hx , i.e., ∀i ∈
{1, . . . , n−1}, mark ai is demoted to mark ai−1 ,
and mark a0 is promoted to mark an−1 .
Hx ++ moves Head Hx on the square immediately
−1
following sx , πx (πx (sx ) + 1).

// Phase 3: Case pM = pM .
∞
if H1l < 0
do
H1r ← n
(H1r ) ← INF
return
od

Hx -- moves Head Hx on the square immediately
−1
preceding sx , πx (πx (sx ) − 1).
The instruction set of M includes if and while statements so to modify the flow of control depending
on arithmetical and logical expressions. The bracket
statements do and od can be used for grouping the argument of if and while statements as well as a whole
instruction table, which is declared via the proc statement. Keyword call invokes an instruction table. Control returns to the caller as soon as the callee executes
instruction return. Let us furthermore suppose there

// Moves H1r beyond coding of pM . . .
// . . . stores the INF flag. . .
// . . . and stops.

// Phase 4: Case pM = pM :
∞
// an inversion, i.e., (H1l ) < (H1r ) has been found.

H2 ← (H1l )
3
(H2 ) ++

// (H1l ) is accounted on Tape 2.

P ROOF We need to show that Phases 2, 5, and 7 stop
in linear time. Phase 2 stops either

// Phase 5: Looks on Tape 2 for the least previously
// recorded digit which is greater than (H1l ).

H2 ++
while (H2 ) = 0
do // skip them.
H2 ++
od

1. when (H1l ) < (H1r ), i.e., in the presence of an
inversion, or
2. when Head H1l goes out of the “left” boundary
of the coding of p.

// While there are empty entries,

Both heads of Tape 1 are shifted leftward of one square
by executing action H1r -- , so Condition 2 is going to
be met after at most n cycles. No other movement in
Tape 1 is commanded within that cycle. The two other
actions in that cycle count on Tape 2 the occurrences
of visited marks of Tape 1.
Obviously Condition 1 implies that p is NIF. The heads
of Tape 1 lay onto the inversion when Phase 2 is exited
in this case. Condition 2 implies that p is INF, i.e.,
p = pM . Phase 3 takes care of this possibility—the
∞
−1
nature of p is recorded on π1 (n) and the procedure
stops.
If Phase 4 is being executed then we are in the case
of Condition 1. This Phase accounts (H1l ) as well
on Tape 2. When Phase 4 terminates, H2 lays onto
−1
square s = π2 (o( (H1l ) )). As p is NIF, and as
((H1l ), (H1r )) represents an inversion, there is at least
one square of Tape 2, say t, such that both the following conditions hold:

// Phase 6: Swaps (H1l ) and (H2 ).
(H1l ) ← H2
(H2 ) -H1l ++
// Phase 7: Piles up the digits as recorded on Tape 2.
H2 ← 0
while H1l < n
do
if (H2 ) = 0
do
(H1l ) ← H2
H1l ++
(H2 ) -od
else
do
H2 ++
od
od

// Rewinds Head H2 .

1. t is a successor of H2 ,
2. t holds a mark m such that m > (H1l ).
This proves that Phase 5 terminates after at most n − 1
iterations.
At this point Head H2 lays on the first non-zero square
on the “right” of square s. As such, it represents
the least mark accounted on T2 which is greater than
(H1l ). Phase 6 overwrites such mark onto square
(H1l ), “de-accounts” it from T2 , and shifts the heads
of T1 one square to the “right”.
Phase 7 first rewinds Head H2 . The loop then moves
H2 through Tape 2 looking for non-zero squares. For
any such square, the corresponding relative distance,
cast to a mark, overwrites the square Head H1l lays
onto. On each of these overwritings H1l is shifted and
square H2 is decremented. This goes on while H1l
lays on the encoding squares. Head H2 is only moved

// Phase 8: Writes the exit status and returns.
// H1l is already on o−1 (n).
(H1l ) ← NIF // Stores the NIF flag. . .
return
// . . . and stops.
od.
A number of properties of this computational procedure are now to be unraveled.
Theorem 2 Let us suppose that a pM is coded on Tape
1 of M and an n-digit zero is coded onto Tape 2. Then
procedure SUCC always terminates, and it does in linear time at most.
4
when (H2 ) holds a0 = o−1 (0). This Phase then writes
on Tape 1 all and only the marks visited during the
hunt for an inversion, i.e., Tape 1 contains an arrangement, other than the original one, of the same multiset
M : another M -permutation. Furthermore the maximum duration of this Phase is n − 2 iterations, for at
most n − 2 marks differ from a0 .
After Theorem 2 computational procedure SUCC is
found to be an Algorithm [3]. Note also that when
SUCC stops, Tape 2’s encoding is restored to its original value—n-digit number zero.
Theorem 2 allows to show that, if p = pM , then it is
∞
always possible to factorize p as follows:
pM

Theorem 3 (LaR Factorization) If
∃L ⊂ M, R ⊂ M, ai ∈ M , such that:

=

pM
∞

p = pM : In this case let us consider p’s LaR factor∞
ization, pL ai pR for some L, ai , and R. Be k =
∞
minR {j | aj < ai }, and R = {ai } ∪ CR {ak };
then
p = pL ak pR
0
is defined as the successor permutation for permutation p.
p = pM : In this case we say that p is undefined, or
∞
that p = Λ.
Note p = SUCC(p), i.e., Algorithm SUCC computes
the just defined successor of permutation p: if at the
−1
end of computing time square π1 (n) holds INF, then
p = Λ, otherwise the coding of p can be found in the
coding squares of Tape 1.

then

1. pM = pL ai pR .
∞
2. R = ∅ ⇒ ai < max{aj | aj ∈ R}.

Theorem 4 Let p ∈ P M , p = pM . Then the following
∞
two conditions hold:

P ROOF Let us represent pM on the tape of a Turing
machine and instruct the machine so that it scans the
permutation right-to-left, halting at the first couple of
contiguous symbols which is not an inversion, or at
the left of its leftmost character—this is possible due
to Theorem 2. The Head at first stands onto the rightmost character of pM . At the end of processing time
the Head of the machine might

1. p < p .
2. ∃q ∈ P M

p<q<p.

P ROOF Condition 1 follows directly from Theorem 3
and Def. 9. Condition 2 follows by observing that p
and p share the same left substring pL and start differing on the mark directly following that substring. Let
us call a and b these characters resp. in p and p . By
construction, b is the least available character that is
greater than a.

• have moved one position leftward. In this case,
take R = ∅, ai the rightmost symbol of pM ,
and L = CM {ai } (i.e., the complementary set
of {ai } with respect to M ).
• be laying somewhere else within the permutation i.e., the Head’s total number of shifts were
more than 1 and less than n. In this case, let ai
be the symbol the Head stands on; then let L and
R be the two substrings respectively on the left
and on the right of ai (L may also be empty).

3

The nature of Algorithm SUCC

Definition 10 Let p and q be any two permutations of
a given multiset M . Then p is said to precede q by
Algorithm SUCC iff:

It will not be possible to find the Head on the left of
the leftmost character of the permutation, because this
would mean that no inversion had been found. In this
case pM would be equal pM , contradicting the hypoth∞
esis.

z

∃z ∈ N

p

...

Let us denote this property as p
Definition 9 Let p be a permutation of a multiset M .
Then there are two distinct cases:

= q.
q.

Let us consider the following Algorithm:
5
Theorem 5 is the formal proof that algorithm SUCC
does generate each and every permutation of a multiset. In other words, the output set coincides with set P
and Algorithm ITER computes the generating process
of P. Recursive relation p = SUCC(p) is a concise
representation of such process. Furthermore, relation
“ ” coincides with relation “<”.

proc ITER
DEFINE NIF := 0, INF := 1
do
H1l ← n
(H1l ) ← NIF
while (H1l ) = INF
do
call SUCC
// Invokes Algorithm SUCC.
H1l ← n
od
return
od.

4

We formally showed that Algorithm SUCC computes
the successor of a permutation of a multiset M , and
that the process which develops permutations via successive calls of SUCC generates each and every permutation of M in lexicographical order.

Obviously Algorithm ITER takes as input an M permutation and produces all successors of that permutation, until the last permutation is reached.

Acknowledgement This project is partly supported
by the IST-2000-25434 Project “DepAuDE”. Geert
Deconinck is a Postdoctoral Fellow of the Fund for
Scientific Research - Flanders (Belgium) (FWO).

Definition 11 Let p0 and p∞ be the zero and last permutations of a given multiset M . Via Algorithm ITER it
is possible to consider set P = {p0 , p0 , p0 , . . . , p∞ },
the set of all outputs of that Algorithm. Note that P is
linearly ordered by the relation “ ”. Let us call P the
output set.

References
[1] George E. Andrews, Number Theory, W. B. Saunders Co., Philadelphia, 1971.

It is now possible to show that the process of determining a zero permutation and then generating all permutations, successor by successor, by means of Algorithms SUCC and ITER, is equivalent to the process of
generating in lexicographical order all permutations of
a string with multiple occurrences of the same characters in it [4]:

[2] Brian W. Kernighan and Dennis M. Ritchie, “The
C Programming Language,” 2nd edition, PrenticeHall, Englewood Cliffs, N.J., 1988.
[3] Donald E. Knuth, The Art of Computer Programming, Vol.1 (“Fundamental Algorithms”), 2nd edition, (Addison-Wesley, Reading, MA, 1973.

Theorem 5 Given a multiset M , let P (n) be the number of different arrangements that can be observed
starting from p0 and going up to p∞ recursively applying the successor operator (computable via algorithm
SUCC ) i.e.,

[4] E. S. Page and L. B. Wilson, An Introduction to
Computational Combinatorics, Cambridge University Press, Cambridge, 1979.
[5] Bjarne Stroustrup, “The C++ Programming Language,” 2nd edition, Addison-Wesley, Reading,
MA, 1995.

z

P (n) = z + 1 ⇔ p0

...

Conclusions

= p∞ .

n
Then P (n) = c0 , c1 , . . . , cm−1 .

[6] Alan M. Turing, “On computable numbers, with
an application to the Entscheidungsproblem,”
Proc. London Math. Soc. Vol.42, 1936, pp. 230–
265.

P ROOF The proof follows by induction over n. It is
left as an exercise to the reader.

6

More Related Content

What's hot

Fourier Series - Engineering Mathematics
Fourier Series -  Engineering MathematicsFourier Series -  Engineering Mathematics
Fourier Series - Engineering MathematicsMd Sadequl Islam
 
2 polar graphs
2 polar graphs2 polar graphs
2 polar graphsmath267
 
Consistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticConsistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticYamagata Yoriyuki
 
Line Segment Intersections
Line Segment IntersectionsLine Segment Intersections
Line Segment IntersectionsBenjamin Sach
 
Lesson 19: The Mean Value Theorem (slides)
Lesson 19: The Mean Value Theorem (slides)Lesson 19: The Mean Value Theorem (slides)
Lesson 19: The Mean Value Theorem (slides)Matthew Leingang
 
Fourier series and fourier integral
Fourier series and fourier integralFourier series and fourier integral
Fourier series and fourier integralashuuhsaqwe
 
differentiate free
differentiate freedifferentiate free
differentiate freelydmilaroy
 
Application of partial derivatives
Application of partial derivativesApplication of partial derivatives
Application of partial derivativesMaharshi Dave
 
aem : Fourier series of Even and Odd Function
aem :  Fourier series of Even and Odd Functionaem :  Fourier series of Even and Odd Function
aem : Fourier series of Even and Odd FunctionSukhvinder Singh
 
Application of partial derivatives with two variables
Application of partial derivatives with two variablesApplication of partial derivatives with two variables
Application of partial derivatives with two variablesSagar Patel
 
Unit vii
Unit viiUnit vii
Unit viimrecedu
 
Half range sine and cosine series
Half range sine and cosine seriesHalf range sine and cosine series
Half range sine and cosine seriesChandan S
 

What's hot (20)

Fourier Series - Engineering Mathematics
Fourier Series -  Engineering MathematicsFourier Series -  Engineering Mathematics
Fourier Series - Engineering Mathematics
 
American option
American optionAmerican option
American option
 
2 polar graphs
2 polar graphs2 polar graphs
2 polar graphs
 
Rolles theorem
Rolles theoremRolles theorem
Rolles theorem
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
 
Consistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmeticConsistency proof of a feasible arithmetic inside a bounded arithmetic
Consistency proof of a feasible arithmetic inside a bounded arithmetic
 
Taylor series
Taylor seriesTaylor series
Taylor series
 
Line Segment Intersections
Line Segment IntersectionsLine Segment Intersections
Line Segment Intersections
 
Lesson 19: The Mean Value Theorem (slides)
Lesson 19: The Mean Value Theorem (slides)Lesson 19: The Mean Value Theorem (slides)
Lesson 19: The Mean Value Theorem (slides)
 
Daa chapter9
Daa chapter9Daa chapter9
Daa chapter9
 
Approximation Algorithms
Approximation AlgorithmsApproximation Algorithms
Approximation Algorithms
 
MEAN VALUE THEOREM
MEAN VALUE THEOREMMEAN VALUE THEOREM
MEAN VALUE THEOREM
 
Fourier series and fourier integral
Fourier series and fourier integralFourier series and fourier integral
Fourier series and fourier integral
 
differentiate free
differentiate freedifferentiate free
differentiate free
 
Application of partial derivatives
Application of partial derivativesApplication of partial derivatives
Application of partial derivatives
 
26 Computational Geometry
26 Computational Geometry26 Computational Geometry
26 Computational Geometry
 
aem : Fourier series of Even and Odd Function
aem :  Fourier series of Even and Odd Functionaem :  Fourier series of Even and Odd Function
aem : Fourier series of Even and Odd Function
 
Application of partial derivatives with two variables
Application of partial derivatives with two variablesApplication of partial derivatives with two variables
Application of partial derivatives with two variables
 
Unit vii
Unit viiUnit vii
Unit vii
 
Half range sine and cosine series
Half range sine and cosine seriesHalf range sine and cosine series
Half range sine and cosine series
 

Similar to Generating Permutations of a Multiset

Theoryofcomp science
Theoryofcomp scienceTheoryofcomp science
Theoryofcomp scienceRaghu nath
 
Programmable PN Sequence Generators
Programmable PN Sequence GeneratorsProgrammable PN Sequence Generators
Programmable PN Sequence GeneratorsRajesh Singh
 
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...BRNSS Publication Hub
 
01 EC 7311-Module IV.pptx
01 EC 7311-Module IV.pptx01 EC 7311-Module IV.pptx
01 EC 7311-Module IV.pptxVSUDHEER4
 
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidFourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidXavier Davias
 
Dynamical systems solved ex
Dynamical systems solved exDynamical systems solved ex
Dynamical systems solved exMaths Tutoring
 
型理論 なんて自分には関係ないと思っているあなたへ
型理論 なんて自分には関係ないと思っているあなたへ型理論 なんて自分には関係ないと思っているあなたへ
型理論 なんて自分には関係ないと思っているあなたへYusuke Matsushita
 
Convexity in the Theory of the Gamma Function.pdf
Convexity in the Theory of the Gamma Function.pdfConvexity in the Theory of the Gamma Function.pdf
Convexity in the Theory of the Gamma Function.pdfPeterEsnayderBarranz
 
Average Polynomial Time Complexity Of Some NP-Complete Problems
Average Polynomial Time Complexity Of Some NP-Complete ProblemsAverage Polynomial Time Complexity Of Some NP-Complete Problems
Average Polynomial Time Complexity Of Some NP-Complete ProblemsAudrey Britton
 
Mean Value Theorem explained with examples.pptx
Mean Value Theorem explained with examples.pptxMean Value Theorem explained with examples.pptx
Mean Value Theorem explained with examples.pptxvandijkvvd4
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithmsDr. Rupa Ch
 

Similar to Generating Permutations of a Multiset (20)

Assignment 2 solution acs
Assignment 2 solution acsAssignment 2 solution acs
Assignment 2 solution acs
 
Design & Analysis of Algorithms Assignment Help
Design & Analysis of Algorithms Assignment HelpDesign & Analysis of Algorithms Assignment Help
Design & Analysis of Algorithms Assignment Help
 
Theoryofcomp science
Theoryofcomp scienceTheoryofcomp science
Theoryofcomp science
 
Chap14_combined.ppt
Chap14_combined.pptChap14_combined.ppt
Chap14_combined.ppt
 
Euler Method
Euler MethodEuler Method
Euler Method
 
Programmable PN Sequence Generators
Programmable PN Sequence GeneratorsProgrammable PN Sequence Generators
Programmable PN Sequence Generators
 
06_AJMS_256_20-compressed.pdf
06_AJMS_256_20-compressed.pdf06_AJMS_256_20-compressed.pdf
06_AJMS_256_20-compressed.pdf
 
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
Solving High-order Non-linear Partial Differential Equations by Modified q-Ho...
 
01 EC 7311-Module IV.pptx
01 EC 7311-Module IV.pptx01 EC 7311-Module IV.pptx
01 EC 7311-Module IV.pptx
 
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoidFourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
 
Dynamical systems solved ex
Dynamical systems solved exDynamical systems solved ex
Dynamical systems solved ex
 
Derivatie class 12
Derivatie class 12Derivatie class 12
Derivatie class 12
 
senior seminar
senior seminarsenior seminar
senior seminar
 
stochastic processes assignment help
stochastic processes assignment helpstochastic processes assignment help
stochastic processes assignment help
 
型理論 なんて自分には関係ないと思っているあなたへ
型理論 なんて自分には関係ないと思っているあなたへ型理論 なんて自分には関係ないと思っているあなたへ
型理論 なんて自分には関係ないと思っているあなたへ
 
Convexity in the Theory of the Gamma Function.pdf
Convexity in the Theory of the Gamma Function.pdfConvexity in the Theory of the Gamma Function.pdf
Convexity in the Theory of the Gamma Function.pdf
 
Saurav's spain paper regards, ajay mishra 324368521
Saurav's spain paper regards, ajay mishra 324368521Saurav's spain paper regards, ajay mishra 324368521
Saurav's spain paper regards, ajay mishra 324368521
 
Average Polynomial Time Complexity Of Some NP-Complete Problems
Average Polynomial Time Complexity Of Some NP-Complete ProblemsAverage Polynomial Time Complexity Of Some NP-Complete Problems
Average Polynomial Time Complexity Of Some NP-Complete Problems
 
Mean Value Theorem explained with examples.pptx
Mean Value Theorem explained with examples.pptxMean Value Theorem explained with examples.pptx
Mean Value Theorem explained with examples.pptx
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithms
 

More from Vincenzo De Florio

Models and Concepts for Socio-technical Complex Systems: Towards Fractal Soci...
Models and Concepts for Socio-technical Complex Systems: Towards Fractal Soci...Models and Concepts for Socio-technical Complex Systems: Towards Fractal Soci...
Models and Concepts for Socio-technical Complex Systems: Towards Fractal Soci...Vincenzo De Florio
 
On the Role of Perception and Apperception in Ubiquitous and Pervasive Enviro...
On the Role of Perception and Apperception in Ubiquitous and Pervasive Enviro...On the Role of Perception and Apperception in Ubiquitous and Pervasive Enviro...
On the Role of Perception and Apperception in Ubiquitous and Pervasive Enviro...Vincenzo De Florio
 
Service-oriented Communities: A Novel Organizational Architecture for Smarter...
Service-oriented Communities: A Novel Organizational Architecture for Smarter...Service-oriented Communities: A Novel Organizational Architecture for Smarter...
Service-oriented Communities: A Novel Organizational Architecture for Smarter...Vincenzo De Florio
 
On codes, machines, and environments: reflections and experiences
On codes, machines, and environments: reflections and experiencesOn codes, machines, and environments: reflections and experiences
On codes, machines, and environments: reflections and experiencesVincenzo De Florio
 
Tapping Into the Wells of Social Energy: A Case Study Based on Falls Identifi...
Tapping Into the Wells of Social Energy: A Case Study Based on Falls Identifi...Tapping Into the Wells of Social Energy: A Case Study Based on Falls Identifi...
Tapping Into the Wells of Social Energy: A Case Study Based on Falls Identifi...Vincenzo De Florio
 
How Resilient Are Our Societies? Analyses, Models, Preliminary Results
How Resilient Are Our Societies?Analyses, Models, Preliminary ResultsHow Resilient Are Our Societies?Analyses, Models, Preliminary Results
How Resilient Are Our Societies? Analyses, Models, Preliminary ResultsVincenzo De Florio
 
Advanced C Language for Engineering
Advanced C Language for EngineeringAdvanced C Language for Engineering
Advanced C Language for EngineeringVincenzo De Florio
 
A framework for trustworthiness assessment based on fidelity in cyber and phy...
A framework for trustworthiness assessment based on fidelity in cyber and phy...A framework for trustworthiness assessment based on fidelity in cyber and phy...
A framework for trustworthiness assessment based on fidelity in cyber and phy...Vincenzo De Florio
 
Fractally-organized Connectionist Networks - Keynote speech @PEWET 2015
Fractally-organized Connectionist Networks - Keynote speech @PEWET 2015Fractally-organized Connectionist Networks - Keynote speech @PEWET 2015
Fractally-organized Connectionist Networks - Keynote speech @PEWET 2015Vincenzo De Florio
 
A behavioural model for the discussion of resilience, elasticity, and antifra...
A behavioural model for the discussion of resilience, elasticity, and antifra...A behavioural model for the discussion of resilience, elasticity, and antifra...
A behavioural model for the discussion of resilience, elasticity, and antifra...Vincenzo De Florio
 
Considerations and ideas after reading a presentation by Ali Anani
Considerations and ideas after reading a presentation by Ali AnaniConsiderations and ideas after reading a presentation by Ali Anani
Considerations and ideas after reading a presentation by Ali AnaniVincenzo De Florio
 
A Behavioral Interpretation of Resilience and Antifragility
A Behavioral Interpretation of Resilience and AntifragilityA Behavioral Interpretation of Resilience and Antifragility
A Behavioral Interpretation of Resilience and AntifragilityVincenzo De Florio
 
Community Resilience: Challenges, Requirements, and Organizational Models
Community Resilience: Challenges, Requirements, and Organizational ModelsCommunity Resilience: Challenges, Requirements, and Organizational Models
Community Resilience: Challenges, Requirements, and Organizational ModelsVincenzo De Florio
 
On the Behavioral Interpretation of System-Environment Fit and Auto-Resilience
On the Behavioral Interpretation of System-Environment Fit and Auto-ResilienceOn the Behavioral Interpretation of System-Environment Fit and Auto-Resilience
On the Behavioral Interpretation of System-Environment Fit and Auto-ResilienceVincenzo De Florio
 
Antifragility = Elasticity + Resilience + Machine Learning. Models and Algori...
Antifragility = Elasticity + Resilience + Machine Learning. Models and Algori...Antifragility = Elasticity + Resilience + Machine Learning. Models and Algori...
Antifragility = Elasticity + Resilience + Machine Learning. Models and Algori...Vincenzo De Florio
 
Service-oriented Communities and Fractal Social Organizations - Models and co...
Service-oriented Communities and Fractal Social Organizations - Models and co...Service-oriented Communities and Fractal Social Organizations - Models and co...
Service-oriented Communities and Fractal Social Organizations - Models and co...Vincenzo De Florio
 
Seminarie Computernetwerken 2012-2013: Lecture I, 26-02-2013
Seminarie Computernetwerken 2012-2013: Lecture I, 26-02-2013Seminarie Computernetwerken 2012-2013: Lecture I, 26-02-2013
Seminarie Computernetwerken 2012-2013: Lecture I, 26-02-2013Vincenzo De Florio
 
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMINGTOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMINGVincenzo De Florio
 
A FAULT-TOLERANCE LINGUISTIC STRUCTURE FOR DISTRIBUTED APPLICATIONS
A FAULT-TOLERANCE LINGUISTIC STRUCTURE FOR DISTRIBUTED APPLICATIONSA FAULT-TOLERANCE LINGUISTIC STRUCTURE FOR DISTRIBUTED APPLICATIONS
A FAULT-TOLERANCE LINGUISTIC STRUCTURE FOR DISTRIBUTED APPLICATIONSVincenzo De Florio
 

More from Vincenzo De Florio (20)

My little grundgestalten
My little grundgestaltenMy little grundgestalten
My little grundgestalten
 
Models and Concepts for Socio-technical Complex Systems: Towards Fractal Soci...
Models and Concepts for Socio-technical Complex Systems: Towards Fractal Soci...Models and Concepts for Socio-technical Complex Systems: Towards Fractal Soci...
Models and Concepts for Socio-technical Complex Systems: Towards Fractal Soci...
 
On the Role of Perception and Apperception in Ubiquitous and Pervasive Enviro...
On the Role of Perception and Apperception in Ubiquitous and Pervasive Enviro...On the Role of Perception and Apperception in Ubiquitous and Pervasive Enviro...
On the Role of Perception and Apperception in Ubiquitous and Pervasive Enviro...
 
Service-oriented Communities: A Novel Organizational Architecture for Smarter...
Service-oriented Communities: A Novel Organizational Architecture for Smarter...Service-oriented Communities: A Novel Organizational Architecture for Smarter...
Service-oriented Communities: A Novel Organizational Architecture for Smarter...
 
On codes, machines, and environments: reflections and experiences
On codes, machines, and environments: reflections and experiencesOn codes, machines, and environments: reflections and experiences
On codes, machines, and environments: reflections and experiences
 
Tapping Into the Wells of Social Energy: A Case Study Based on Falls Identifi...
Tapping Into the Wells of Social Energy: A Case Study Based on Falls Identifi...Tapping Into the Wells of Social Energy: A Case Study Based on Falls Identifi...
Tapping Into the Wells of Social Energy: A Case Study Based on Falls Identifi...
 
How Resilient Are Our Societies? Analyses, Models, Preliminary Results
How Resilient Are Our Societies?Analyses, Models, Preliminary ResultsHow Resilient Are Our Societies?Analyses, Models, Preliminary Results
How Resilient Are Our Societies? Analyses, Models, Preliminary Results
 
Advanced C Language for Engineering
Advanced C Language for EngineeringAdvanced C Language for Engineering
Advanced C Language for Engineering
 
A framework for trustworthiness assessment based on fidelity in cyber and phy...
A framework for trustworthiness assessment based on fidelity in cyber and phy...A framework for trustworthiness assessment based on fidelity in cyber and phy...
A framework for trustworthiness assessment based on fidelity in cyber and phy...
 
Fractally-organized Connectionist Networks - Keynote speech @PEWET 2015
Fractally-organized Connectionist Networks - Keynote speech @PEWET 2015Fractally-organized Connectionist Networks - Keynote speech @PEWET 2015
Fractally-organized Connectionist Networks - Keynote speech @PEWET 2015
 
A behavioural model for the discussion of resilience, elasticity, and antifra...
A behavioural model for the discussion of resilience, elasticity, and antifra...A behavioural model for the discussion of resilience, elasticity, and antifra...
A behavioural model for the discussion of resilience, elasticity, and antifra...
 
Considerations and ideas after reading a presentation by Ali Anani
Considerations and ideas after reading a presentation by Ali AnaniConsiderations and ideas after reading a presentation by Ali Anani
Considerations and ideas after reading a presentation by Ali Anani
 
A Behavioral Interpretation of Resilience and Antifragility
A Behavioral Interpretation of Resilience and AntifragilityA Behavioral Interpretation of Resilience and Antifragility
A Behavioral Interpretation of Resilience and Antifragility
 
Community Resilience: Challenges, Requirements, and Organizational Models
Community Resilience: Challenges, Requirements, and Organizational ModelsCommunity Resilience: Challenges, Requirements, and Organizational Models
Community Resilience: Challenges, Requirements, and Organizational Models
 
On the Behavioral Interpretation of System-Environment Fit and Auto-Resilience
On the Behavioral Interpretation of System-Environment Fit and Auto-ResilienceOn the Behavioral Interpretation of System-Environment Fit and Auto-Resilience
On the Behavioral Interpretation of System-Environment Fit and Auto-Resilience
 
Antifragility = Elasticity + Resilience + Machine Learning. Models and Algori...
Antifragility = Elasticity + Resilience + Machine Learning. Models and Algori...Antifragility = Elasticity + Resilience + Machine Learning. Models and Algori...
Antifragility = Elasticity + Resilience + Machine Learning. Models and Algori...
 
Service-oriented Communities and Fractal Social Organizations - Models and co...
Service-oriented Communities and Fractal Social Organizations - Models and co...Service-oriented Communities and Fractal Social Organizations - Models and co...
Service-oriented Communities and Fractal Social Organizations - Models and co...
 
Seminarie Computernetwerken 2012-2013: Lecture I, 26-02-2013
Seminarie Computernetwerken 2012-2013: Lecture I, 26-02-2013Seminarie Computernetwerken 2012-2013: Lecture I, 26-02-2013
Seminarie Computernetwerken 2012-2013: Lecture I, 26-02-2013
 
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMINGTOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
TOWARDS PARSIMONIOUS RESOURCE ALLOCATION IN CONTEXT-AWARE N-VERSION PROGRAMMING
 
A FAULT-TOLERANCE LINGUISTIC STRUCTURE FOR DISTRIBUTED APPLICATIONS
A FAULT-TOLERANCE LINGUISTIC STRUCTURE FOR DISTRIBUTED APPLICATIONSA FAULT-TOLERANCE LINGUISTIC STRUCTURE FOR DISTRIBUTED APPLICATIONS
A FAULT-TOLERANCE LINGUISTIC STRUCTURE FOR DISTRIBUTED APPLICATIONS
 

Recently uploaded

ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Recently uploaded (20)

LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

Generating Permutations of a Multiset

  • 1. A Formal Model and an Algorithm for Generating the Permutations of a Multiset VINCENZO DE FLORIO and GEERT DECONINCK Electrical Engineering Department – ESAT Katholieke Universiteit Leuven, Kasteelpark Arenberg 10, 3001 Leuven-Heverlee BELGIUM Abstract: – This paper may be considered as a mathematical divertissement as well as a didactical tool for undergraduate students in a universitary course on algorithms and computation. The well-known problem of generating the permutations of a multiset of marks is considered. We define a formal model and an abstract machine (an extended Turing machine). Then we write an algorithm to compute on that machine the successor of a given permutation in the lexicographically ordered set of permutations of a multiset. Within the model we analyze the algorithm, prove its correctness, and show that the algorithm solves the above problem. Then we describe a slight modification of the algorithm and we analyze in which cases it may result in an improvement of execution times. Key-Words: – Computational combinatorics, permutations, Turing machines, algorithms, number theory. 1 Introduction {0, 1, . . . , n − 1}. Let furthermore m be an integer, 0 < m ≤ n. The problem of generating the permutations of a multiset of marks is considered. First some mathematical entities and properties are defined within a formal model. Then an abstract machine is introduced and an algorithm is shown which computes those entities on the abstract machine. Within this framework the algorithm is analyzed and proved to be correct. Finally it is shown that the algorithm computes the successor of a given permutation in the ordered set of lexicographically ordered permutations. The structure of this work is as follows: the formal model, the machine and the algorithm are described in Section 2. Section 3 deals with the link between the algorithm and the process of generating the permutations of a multiset in lexicographical order. Some conclusions are drawn in Section 4. 2 2.1 Definition 1 Set A = {a0 , a1 , . . . , am−1 } be called “the Alphabet”. Let Im = {0, 1, . . . , m − 1}. Let us consider multiset M = {a0 , . . . , a0 , a1 , . . . , a1 , · · · , am−1 , . . . , am−1 } c0 such that i∈Im ci c1 cm−1 = n and ∀i ∈ Im : ci > 0. Definition 2 Any ordered arrangement of the elements of a multiset M be called M -permutation and represented as pM or, where M is evident from the context, as p. Let pM [i] (or p[i]) denote the (i + 1)th element of p. Let us call P M (or simply P when unambiguous) the set of the M -permutations. A machine and an algorithm Let o : An → In be a bijection defined so that ∀i ∈ In : o(ai ) = i. Clearly o induces a total order on the marks (and, a fortiori, on the elements of the Alphabet). Furthermore, through o, any M -permutation may be interpreted as an n-digit, base-m number [1]. Prologue—some definitions Let n be an integer, n > 2, and let An = {a0 , a1 , . . . , an−1 } be a set of “marks”. Let In be set 1
  • 2. 2.2 Definition 3 Given multiset M as above, arrangement Let us consider M, a generalized Turing machine [6] with two tapes, T1 and T2 , and three heads, H1l , H1r , and H2 . Heads H1l and H1r are “jointed”, i.e., capable of reading or writing any two consecutive squares of T1 at a time. H2 operates on T2 . Let us call S1 and S2 resp. the set of squares of T1 and the set of squares of T2 . a0 · · · · · a0 · a1 · · · · · a1 · · · am−1 · · · · · am−1 c0 c1 A machine cm−1 is called the zero permutation of M , or briefly its zero, and is denoted as pM or simply as p0 when this can be 0 done unambiguously. For the sake of brevity, operator “·”, concatenating any two marks, will be omitted in the following. Definition 7 Be s a square; square s then represents the square which immediately follows s. For any t ∈ N t Definition 4 Given multiset M as above, arrangement let s cm−2 represent square ((. . . ( s ) . . . ) . Definition 8 Let z1 ∈ S1 . such that   π1 (s) = 0    π1 (s) = t       ∀s ∈ S1 :   π1 (s) = −t         am−1 . . . am−1 am−2 . . . am−2 · · · a0 . . . a0 cm−1 ... c0 is called the last permutation of M and is denoted as pM . ∞ Definition 5 Given any two M -permutations, p1 and p2 : • p1 is said to be equal to p2 iff ∀i ∈ In : p1 [i] = p2 [i]. Let p1 = p2 represent this property. t t Bijection π1 : S1 → Z, if s = z1 , if s = z1 and ∃t ∈ N t (s = z1 . . . ), if s = z1 and ∃t ∈ N t (z1 = s ... ), is called the relative distance from z1 in S1 . Following the same procedure, let π2 : S2 → Z be the relative distance from a fixed z2 ∈ S2 . • p1 and p2 are said to be different iff ¬(p1 = p2 ), or p1 = p2 for brevity. From Def. 2, any M -permutation p can be coded on Tape T1 of M by writing, ∀i ∈ In , mark p[i] onto • p1 < p2 iff ∃k ∈ In (∀j < k : p1 [j] = p2 [j]) ∧ (p1 [k] < p2 [k]). i Theorem 1 For any M , pM is the only possible INF∞ permutation. −1 square π1 (i), i.e., onto square z1 . . . . Machine M can execute read, write and headmovement actions. These basic actions can be described via the following symbolic notation: Let i be an integer and Hx and Hy be heads respectively operating on Tape Tx and Tape Ty (possibly the same). Let sx be the square under Head Hx and sy the square under Hy . Let us call πx and πy the relative distances respectively for Tx and Ty (possibly equal). Let r be a function converting a square into the mark currently coded onto that square. Then let: P ROOF By construction, pM is INF. Ab absurdo, let us ∞ suppose there exists a permutation p = pM which is ∞ INF. Then either p < pM or vice-versa. In both cases ∞ we reach a contradiction by Def. 5. . (Hx ) represent the output of a read of square sx , available as o(r(sx )) ∈ Im , and let Hx represent the position of Head Hx , available as πx (sx ) ∈ Z. Definition 6 Let p ∈ P M . An inversion is a couple of contiguous marks of p, p[i] and p[i + 1], i ∈ {0, . . . , n − 2}, such that p[i] < p[i + 1]. If no such couple can be found in p, then p is said to be inversionfree (INF). If at least one such couple does exist, then p is said to be non-inversion-free (NIF). 2
  • 3. exists a symbolic assembler such that it is possible to define symbolic constants by means of the pseudoinstruction DEFINE. Comments are also supported— string “//” denotes the beginning of a comment which continues up to the end of the line. Finally, let us suppose that each of the above instructions, including each evaluation of a Boolean or arithmetical atom, lasts the same amount of time. The infix, “overloaded” (in the sense of [5]) operator “←” be used to represent both writings of squares and absolute movements of heads as described below: (Hx ) ← i writes in sx mark o−1 (i mod n), (Hx ) ← (Hy ) in sy , overwrites sx with the mark written (Hx ) ← Hy overwrites sx with mark −1 (π (s ) mod n), o y y Hx ← i 2.3 −1 moves Head Hx over square πx (i), Hx By means of the above just sketched agreements it is possible to compose the following computational procedure: ← (Hy ) moves Head Hx over square −1 πx (o(r(sy ))), Hx An algorithm for machine M ← Hy moves Head Hx over square −1 πx (πy (sy )). proc SUCC DEFINE NIF := 0 DEFINE INF := 1 do Postfix operators “ ++ ” and “ -- ”, borrowed from the grammar of the C programming language [2], are used to represent incremental / decremental writings and relative, single-square movements as follows: // pM has found to be NIF. // pM has found to be INF. // Phase 1: Heads H1l and H1r are moved on the // last couple of squares of the encoding of pM onto Tape 1. // H1r is on the last such square, H1l on the last but one. (Hx ) ++ increments, modulo n, the number coded in the square under Head Hx , i.e., ∀i ∈ {0, . . . , n − 2}, mark ai is promoted to mark ai+1 , and mark an−1 is demoted to mark a0 . H1r ← n − 1 while (H1l ) ≥ (H1r ) ∧ H1l ≥ 0 do H1r -H2 ← (H1r ) (H2 ) ++ od (Hx ) -- decrements, modulo n, the number coded in the square under Head Hx , i.e., ∀i ∈ {1, . . . , n−1}, mark ai is demoted to mark ai−1 , and mark a0 is promoted to mark an−1 . Hx ++ moves Head Hx on the square immediately −1 following sx , πx (πx (sx ) + 1). // Phase 3: Case pM = pM . ∞ if H1l < 0 do H1r ← n (H1r ) ← INF return od Hx -- moves Head Hx on the square immediately −1 preceding sx , πx (πx (sx ) − 1). The instruction set of M includes if and while statements so to modify the flow of control depending on arithmetical and logical expressions. The bracket statements do and od can be used for grouping the argument of if and while statements as well as a whole instruction table, which is declared via the proc statement. Keyword call invokes an instruction table. Control returns to the caller as soon as the callee executes instruction return. Let us furthermore suppose there // Moves H1r beyond coding of pM . . . // . . . stores the INF flag. . . // . . . and stops. // Phase 4: Case pM = pM : ∞ // an inversion, i.e., (H1l ) < (H1r ) has been found. H2 ← (H1l ) 3
  • 4. (H2 ) ++ // (H1l ) is accounted on Tape 2. P ROOF We need to show that Phases 2, 5, and 7 stop in linear time. Phase 2 stops either // Phase 5: Looks on Tape 2 for the least previously // recorded digit which is greater than (H1l ). H2 ++ while (H2 ) = 0 do // skip them. H2 ++ od 1. when (H1l ) < (H1r ), i.e., in the presence of an inversion, or 2. when Head H1l goes out of the “left” boundary of the coding of p. // While there are empty entries, Both heads of Tape 1 are shifted leftward of one square by executing action H1r -- , so Condition 2 is going to be met after at most n cycles. No other movement in Tape 1 is commanded within that cycle. The two other actions in that cycle count on Tape 2 the occurrences of visited marks of Tape 1. Obviously Condition 1 implies that p is NIF. The heads of Tape 1 lay onto the inversion when Phase 2 is exited in this case. Condition 2 implies that p is INF, i.e., p = pM . Phase 3 takes care of this possibility—the ∞ −1 nature of p is recorded on π1 (n) and the procedure stops. If Phase 4 is being executed then we are in the case of Condition 1. This Phase accounts (H1l ) as well on Tape 2. When Phase 4 terminates, H2 lays onto −1 square s = π2 (o( (H1l ) )). As p is NIF, and as ((H1l ), (H1r )) represents an inversion, there is at least one square of Tape 2, say t, such that both the following conditions hold: // Phase 6: Swaps (H1l ) and (H2 ). (H1l ) ← H2 (H2 ) -H1l ++ // Phase 7: Piles up the digits as recorded on Tape 2. H2 ← 0 while H1l < n do if (H2 ) = 0 do (H1l ) ← H2 H1l ++ (H2 ) -od else do H2 ++ od od // Rewinds Head H2 . 1. t is a successor of H2 , 2. t holds a mark m such that m > (H1l ). This proves that Phase 5 terminates after at most n − 1 iterations. At this point Head H2 lays on the first non-zero square on the “right” of square s. As such, it represents the least mark accounted on T2 which is greater than (H1l ). Phase 6 overwrites such mark onto square (H1l ), “de-accounts” it from T2 , and shifts the heads of T1 one square to the “right”. Phase 7 first rewinds Head H2 . The loop then moves H2 through Tape 2 looking for non-zero squares. For any such square, the corresponding relative distance, cast to a mark, overwrites the square Head H1l lays onto. On each of these overwritings H1l is shifted and square H2 is decremented. This goes on while H1l lays on the encoding squares. Head H2 is only moved // Phase 8: Writes the exit status and returns. // H1l is already on o−1 (n). (H1l ) ← NIF // Stores the NIF flag. . . return // . . . and stops. od. A number of properties of this computational procedure are now to be unraveled. Theorem 2 Let us suppose that a pM is coded on Tape 1 of M and an n-digit zero is coded onto Tape 2. Then procedure SUCC always terminates, and it does in linear time at most. 4
  • 5. when (H2 ) holds a0 = o−1 (0). This Phase then writes on Tape 1 all and only the marks visited during the hunt for an inversion, i.e., Tape 1 contains an arrangement, other than the original one, of the same multiset M : another M -permutation. Furthermore the maximum duration of this Phase is n − 2 iterations, for at most n − 2 marks differ from a0 . After Theorem 2 computational procedure SUCC is found to be an Algorithm [3]. Note also that when SUCC stops, Tape 2’s encoding is restored to its original value—n-digit number zero. Theorem 2 allows to show that, if p = pM , then it is ∞ always possible to factorize p as follows: pM Theorem 3 (LaR Factorization) If ∃L ⊂ M, R ⊂ M, ai ∈ M , such that: = pM ∞ p = pM : In this case let us consider p’s LaR factor∞ ization, pL ai pR for some L, ai , and R. Be k = ∞ minR {j | aj < ai }, and R = {ai } ∪ CR {ak }; then p = pL ak pR 0 is defined as the successor permutation for permutation p. p = pM : In this case we say that p is undefined, or ∞ that p = Λ. Note p = SUCC(p), i.e., Algorithm SUCC computes the just defined successor of permutation p: if at the −1 end of computing time square π1 (n) holds INF, then p = Λ, otherwise the coding of p can be found in the coding squares of Tape 1. then 1. pM = pL ai pR . ∞ 2. R = ∅ ⇒ ai < max{aj | aj ∈ R}. Theorem 4 Let p ∈ P M , p = pM . Then the following ∞ two conditions hold: P ROOF Let us represent pM on the tape of a Turing machine and instruct the machine so that it scans the permutation right-to-left, halting at the first couple of contiguous symbols which is not an inversion, or at the left of its leftmost character—this is possible due to Theorem 2. The Head at first stands onto the rightmost character of pM . At the end of processing time the Head of the machine might 1. p < p . 2. ∃q ∈ P M p<q<p. P ROOF Condition 1 follows directly from Theorem 3 and Def. 9. Condition 2 follows by observing that p and p share the same left substring pL and start differing on the mark directly following that substring. Let us call a and b these characters resp. in p and p . By construction, b is the least available character that is greater than a. • have moved one position leftward. In this case, take R = ∅, ai the rightmost symbol of pM , and L = CM {ai } (i.e., the complementary set of {ai } with respect to M ). • be laying somewhere else within the permutation i.e., the Head’s total number of shifts were more than 1 and less than n. In this case, let ai be the symbol the Head stands on; then let L and R be the two substrings respectively on the left and on the right of ai (L may also be empty). 3 The nature of Algorithm SUCC Definition 10 Let p and q be any two permutations of a given multiset M . Then p is said to precede q by Algorithm SUCC iff: It will not be possible to find the Head on the left of the leftmost character of the permutation, because this would mean that no inversion had been found. In this case pM would be equal pM , contradicting the hypoth∞ esis. z ∃z ∈ N p ... Let us denote this property as p Definition 9 Let p be a permutation of a multiset M . Then there are two distinct cases: = q. q. Let us consider the following Algorithm: 5
  • 6. Theorem 5 is the formal proof that algorithm SUCC does generate each and every permutation of a multiset. In other words, the output set coincides with set P and Algorithm ITER computes the generating process of P. Recursive relation p = SUCC(p) is a concise representation of such process. Furthermore, relation “ ” coincides with relation “<”. proc ITER DEFINE NIF := 0, INF := 1 do H1l ← n (H1l ) ← NIF while (H1l ) = INF do call SUCC // Invokes Algorithm SUCC. H1l ← n od return od. 4 We formally showed that Algorithm SUCC computes the successor of a permutation of a multiset M , and that the process which develops permutations via successive calls of SUCC generates each and every permutation of M in lexicographical order. Obviously Algorithm ITER takes as input an M permutation and produces all successors of that permutation, until the last permutation is reached. Acknowledgement This project is partly supported by the IST-2000-25434 Project “DepAuDE”. Geert Deconinck is a Postdoctoral Fellow of the Fund for Scientific Research - Flanders (Belgium) (FWO). Definition 11 Let p0 and p∞ be the zero and last permutations of a given multiset M . Via Algorithm ITER it is possible to consider set P = {p0 , p0 , p0 , . . . , p∞ }, the set of all outputs of that Algorithm. Note that P is linearly ordered by the relation “ ”. Let us call P the output set. References [1] George E. Andrews, Number Theory, W. B. Saunders Co., Philadelphia, 1971. It is now possible to show that the process of determining a zero permutation and then generating all permutations, successor by successor, by means of Algorithms SUCC and ITER, is equivalent to the process of generating in lexicographical order all permutations of a string with multiple occurrences of the same characters in it [4]: [2] Brian W. Kernighan and Dennis M. Ritchie, “The C Programming Language,” 2nd edition, PrenticeHall, Englewood Cliffs, N.J., 1988. [3] Donald E. Knuth, The Art of Computer Programming, Vol.1 (“Fundamental Algorithms”), 2nd edition, (Addison-Wesley, Reading, MA, 1973. Theorem 5 Given a multiset M , let P (n) be the number of different arrangements that can be observed starting from p0 and going up to p∞ recursively applying the successor operator (computable via algorithm SUCC ) i.e., [4] E. S. Page and L. B. Wilson, An Introduction to Computational Combinatorics, Cambridge University Press, Cambridge, 1979. [5] Bjarne Stroustrup, “The C++ Programming Language,” 2nd edition, Addison-Wesley, Reading, MA, 1995. z P (n) = z + 1 ⇔ p0 ... Conclusions = p∞ . n Then P (n) = c0 , c1 , . . . , cm−1 . [6] Alan M. Turing, “On computable numbers, with an application to the Entscheidungsproblem,” Proc. London Math. Soc. Vol.42, 1936, pp. 230– 265. P ROOF The proof follows by induction over n. It is left as an exercise to the reader. 6