construct the lexicographic successor of a given permutation - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Discrete Mathematics : Combinatorics : combinat : combinat/nextperm

combinat[nextperm] - construct the lexicographic successor of a given permutation

combinat[prevperm] - construct the lexicographic predecessor of a given permutation

combinat[firstperm] - construct the first permutation in lexicographic order

combinat[lastperm] - construct the last permutation in lexicographic order

Calling Sequence

nextperm( p )

prevperm( p )

firstperm( n )

lastperm( n )

Parameters

p

-

permlist; permutation of positive integers from 1 to n for some n

n

-

nonnegint; degree of the permutation

Description

• 

Given a permutation p (of type permlist) of the integers 1 through n, for some n, the command nextperm returns the lexicographic successor of p.

• 

If p is the lexicographically last permutation of degree n (that is, [n,n-1,...,2,1]), then the value FAIL is returned.

• 

Given a permutation p (of type permlist) of the integers 1 through n, for some n, the command prevperm returns the lexicographic predecessor of p.

• 

If p is the first permutation of degree n in lexicographic order (that is, [1,2,...,n-1,n]), then the value FAIL is returned.

• 

The command firstperm returns the first permutation, in lexicographic order, of the permutations of the set {1,2,...,n} of integers from 1 to n. This is the permutation [ 1, 2, ..., n ].

• 

The command lastperm returns the last permutation, in lexicographic order, of the permutations of the set {1,2,...,n} of integers from 1 to n. The lexicographically last permutation of {1,2,...,n} is [n, n-1, ..., 2, 1 ].

Thread Safety

• 

The combinat[nextperm], combinat[prevperm], combinat[firstperm] and combinat[lastperm] commands are thread-safe as of Maple 16.

• 

For more information on thread safety, see index/threadsafe.

Examples

withcombinat

Chi,bell,binomial,cartprod,character,choose,composition,conjpart,decodepart,encodepart,eulerian1,eulerian2,fibonacci,firstcomb,firstpart,firstperm,graycode,inttovec,lastcomb,lastpart,lastperm,multinomial,nextcomb,nextpart,nextperm,numbcomb,numbcomp,numbpart,numbperm,partition,permute,powerset,prevcomb,prevpart,prevperm,randcomb,randpart,randperm,rankcomb,rankperm,setpartition,stirling1,stirling2,subsets,unrankcomb,unrankperm,vectoint

(1)

nextperm1,3,2

2,1,3

(2)

nextperm4,3,2,1

FAIL

(3)

prevperm2,1,3

1,3,2

(4)

prevperm1,2,3,4,5

FAIL

(5)

firstperm4

1,2,3,4

(6)

lastperm3

3,2,1

(7)

See Also

combinat, combinat[permute]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam